Skip to content

Commit 2ec6761

Browse files
tzanussiherbertx
authored andcommitted
crypto: iaa - Add support for deflate-iaa compression algorithm
This patch registers the deflate-iaa deflate compression algorithm and hooks it up to the IAA hardware using the 'fixed' compression mode introduced in the previous patch. Because the IAA hardware has a 4k history-window limitation, only buffers <= 4k, or that have been compressed using a <= 4k history window, are technically compliant with the deflate spec, which allows for a window of up to 32k. Because of this limitation, the IAA fixed mode deflate algorithm is given its own algorithm name, 'deflate-iaa'. With this change, the deflate-iaa crypto algorithm is registered and operational, and compression and decompression operations are fully enabled following the successful binding of the first IAA workqueue to the iaa_crypto sub-driver. when there are no IAA workqueues bound to the driver, the IAA crypto algorithm can be unregistered by removing the module. A new iaa_crypto 'verify_compress' driver attribute is also added, allowing the user to toggle compression verification. If set, each compress will be internally decompressed and the contents verified, returning error codes if unsuccessful. This can be toggled with 0/1: echo 0 > /sys/bus/dsa/drivers/crypto/verify_compress The default setting is '1' - verify all compresses. The verify_compress value setting at the time the algorithm is registered is captured in the algorithm's crypto_ctx and used for all compresses when using the algorithm. [ Based on work originally by George Powley, Jing Lin and Kyung Min Park ] Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent b190447 commit 2ec6761

File tree

3 files changed

+1079
-18
lines changed

3 files changed

+1079
-18
lines changed

crypto/testmgr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4796,6 +4796,16 @@ static const struct alg_test_desc alg_test_descs[] = {
47964796
.decomp = __VECS(deflate_decomp_tv_template)
47974797
}
47984798
}
4799+
}, {
4800+
.alg = "deflate-iaa",
4801+
.test = alg_test_comp,
4802+
.fips_allowed = 1,
4803+
.suite = {
4804+
.comp = {
4805+
.comp = __VECS(deflate_comp_tv_template),
4806+
.decomp = __VECS(deflate_decomp_tv_template)
4807+
}
4808+
}
47994809
}, {
48004810
.alg = "dh",
48014811
.test = alg_test_kpp,

drivers/crypto/intel/iaa/iaa_crypto.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,42 @@
1010

1111
#define IDXD_SUBDRIVER_NAME "crypto"
1212

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)
18+
19+
#define IAA_COMP_FLUSH_OUTPUT BIT(1)
20+
#define IAA_COMP_APPEND_EOB BIT(2)
21+
22+
#define IAA_COMPLETION_TIMEOUT 1000000
23+
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
28+
1329
#define IAA_COMP_MODES_MAX 2
1430

1531
#define FIXED_HDR 0x2
1632
#define FIXED_HDR_SIZE 3
1733

34+
#define IAA_COMP_FLAGS (IAA_COMP_FLUSH_OUTPUT | \
35+
IAA_COMP_APPEND_EOB)
36+
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)
41+
1842
/* Representation of IAA workqueue */
1943
struct iaa_wq {
2044
struct list_head list;
45+
2146
struct idxd_wq *wq;
47+
int ref;
48+
bool remove;
2249

2350
struct iaa_device *iaa_device;
2451
};
@@ -119,4 +146,13 @@ int add_iaa_compression_mode(const char *name,
119146

120147
void remove_iaa_compression_mode(const char *name);
121148

149+
enum iaa_mode {
150+
IAA_MODE_FIXED,
151+
};
152+
153+
struct iaa_compression_ctx {
154+
enum iaa_mode mode;
155+
bool verify_compress;
156+
};
157+
122158
#endif

0 commit comments

Comments
 (0)