1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2021 Intel Corporation. All rights rsvd. */
4 #ifndef __IAA_CRYPTO_H__
5 #define __IAA_CRYPTO_H__
7 #include <linux/crypto.h>
8 #include <linux/idxd.h>
9 #include <uapi/linux/idxd.h>
11 #define IDXD_SUBDRIVER_NAME "crypto"
13 #define IAA_DECOMP_ENABLE BIT(0)
14 #define IAA_DECOMP_FLUSH_OUTPUT BIT(1)
15 #define IAA_DECOMP_CHECK_FOR_EOB BIT(2)
16 #define IAA_DECOMP_STOP_ON_EOB BIT(3)
17 #define IAA_DECOMP_SUPPRESS_OUTPUT BIT(9)
19 #define IAA_COMP_FLUSH_OUTPUT BIT(1)
20 #define IAA_COMP_APPEND_EOB BIT(2)
22 #define IAA_COMPLETION_TIMEOUT 1000000
24 #define IAA_ANALYTICS_ERROR 0x0a
25 #define IAA_ERROR_DECOMP_BUF_OVERFLOW 0x0b
26 #define IAA_ERROR_COMP_BUF_OVERFLOW 0x19
27 #define IAA_ERROR_WATCHDOG_EXPIRED 0x24
29 #define IAA_COMP_MODES_MAX 2
32 #define FIXED_HDR_SIZE 3
34 #define IAA_COMP_FLAGS (IAA_COMP_FLUSH_OUTPUT | \
37 #define IAA_DECOMP_FLAGS (IAA_DECOMP_ENABLE | \
38 IAA_DECOMP_FLUSH_OUTPUT | \
39 IAA_DECOMP_CHECK_FOR_EOB | \
40 IAA_DECOMP_STOP_ON_EOB)
42 /* Representation of IAA workqueue */
44 struct list_head list;
50 struct iaa_device *iaa_device;
58 struct iaa_device_compression_mode {
61 struct aecs_comp_table_record *aecs_comp_table;
63 dma_addr_t aecs_comp_table_dma_addr;
66 /* Representation of IAA device with wqs, populated by probe */
68 struct list_head list;
69 struct idxd_device *idxd;
71 struct iaa_device_compression_mode *compression_modes[IAA_COMP_MODES_MAX];
82 struct wq_table_entry {
89 #define IAA_AECS_ALIGN 32
92 * Analytics Engine Configuration and State (AECS) contains parameters and
93 * internal state of the analytics engine.
95 struct aecs_comp_table_record {
99 u32 num_output_accum_bits;
100 u8 output_accum[256];
105 u32 reserved_padding[2];
108 int iaa_aecs_init_fixed(void);
109 void iaa_aecs_cleanup_fixed(void);
111 typedef int (*iaa_dev_comp_init_fn_t) (struct iaa_device_compression_mode *mode);
112 typedef int (*iaa_dev_comp_free_fn_t) (struct iaa_device_compression_mode *mode);
114 struct iaa_compression_mode {
120 iaa_dev_comp_init_fn_t init;
121 iaa_dev_comp_free_fn_t free;
124 int add_iaa_compression_mode(const char *name,
129 iaa_dev_comp_init_fn_t init,
130 iaa_dev_comp_free_fn_t free);
132 void remove_iaa_compression_mode(const char *name);
138 struct iaa_compression_ctx {
140 bool verify_compress;
145 extern struct list_head iaa_devices;
146 extern struct mutex iaa_devices_lock;