blob: 99f21d848d4ff565a005804dcbe8dccbbbb6f013 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/* Copyright (c) 2019 HiSilicon Limited. */
3#ifndef HISI_ZIP_H
4#define HISI_ZIP_H
5
6#undef pr_fmt
7#define pr_fmt(fmt) "hisi_zip: " fmt
8
9#include <linux/list.h>
10#include "../qm.h"
11#include "../sgl.h"
12
13/* hisi_zip_sqe dw3 */
14#define HZIP_BD_STATUS_M GENMASK(7, 0)
15/* hisi_zip_sqe dw7 */
16#define HZIP_IN_SGE_DATA_OFFSET_M GENMASK(23, 0)
17/* hisi_zip_sqe dw8 */
18#define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0)
19/* hisi_zip_sqe dw9 */
20#define HZIP_REQ_TYPE_M GENMASK(7, 0)
21#define HZIP_ALG_TYPE_ZLIB 0x02
22#define HZIP_ALG_TYPE_GZIP 0x03
23#define HZIP_BUF_TYPE_M GENMASK(11, 8)
24#define HZIP_PBUFFER 0x0
25#define HZIP_SGL 0x1
26
27enum hisi_zip_error_type {
28 /* negative compression */
29 HZIP_NC_ERR = 0x0d,
30};
31
32struct hisi_zip_ctrl;
33
34struct hisi_zip {
35 struct hisi_qm qm;
36 struct list_head list;
37 struct hisi_zip_ctrl *ctrl;
38};
39
40struct hisi_zip_sqe {
41 u32 consumed;
42 u32 produced;
43 u32 comp_data_length;
44 u32 dw3;
45 u32 input_data_length;
46 u32 lba_l;
47 u32 lba_h;
48 u32 dw7;
49 u32 dw8;
50 u32 dw9;
51 u32 dw10;
52 u32 priv_info;
53 u32 dw12;
54 u32 tag;
55 u32 dest_avail_out;
56 u32 rsvd0;
57 u32 comp_head_addr_l;
58 u32 comp_head_addr_h;
59 u32 source_addr_l;
60 u32 source_addr_h;
61 u32 dest_addr_l;
62 u32 dest_addr_h;
63 u32 stream_ctx_addr_l;
64 u32 stream_ctx_addr_h;
65 u32 cipher_key1_addr_l;
66 u32 cipher_key1_addr_h;
67 u32 cipher_key2_addr_l;
68 u32 cipher_key2_addr_h;
69 u32 rsvd1[4];
70};
71
72struct hisi_zip *find_zip_device(int node);
73int hisi_zip_register_to_crypto(void);
74void hisi_zip_unregister_from_crypto(void);
75#endif