Skip to content

Commit 6621e64

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/zip - add debugfs for Hisilicon ZIP
Hisilicon ZIP engine driver uses debugfs to provides IO operation debug information Signed-off-by: Longfang Liu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Reviewed-by: Zaibo Xu <[email protected]> Reviewed-by: Zhou Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 64a6301 commit 6621e64

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

Documentation/ABI/testing/debugfs-hisi-zip

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,29 @@ Contact: [email protected]
8686
Description: Dump the status of the QM.
8787
Four states: initiated, started, stopped and closed.
8888
Available for both PF and VF, and take no other effect on ZIP.
89+
90+
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/send_cnt
91+
Date: Apr 2020
92+
93+
Description: Dump the total number of sent requests.
94+
Available for both PF and VF, and take no other effect on ZIP.
95+
96+
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/recv_cnt
97+
Date: Apr 2020
98+
99+
Description: Dump the total number of received requests.
100+
Available for both PF and VF, and take no other effect on ZIP.
101+
102+
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/send_busy_cnt
103+
Date: Apr 2020
104+
105+
Description: Dump the total number of requests received
106+
with returning busy.
107+
Available for both PF and VF, and take no other effect on ZIP.
108+
109+
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/err_bd_cnt
110+
Date: Apr 2020
111+
112+
Description: Dump the total number of BD type error requests
113+
to be received.
114+
Available for both PF and VF, and take no other effect on ZIP.

drivers/crypto/hisilicon/zip/zip.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,20 @@ enum hisi_zip_error_type {
2828
HZIP_NC_ERR = 0x0d,
2929
};
3030

31+
struct hisi_zip_dfx {
32+
atomic64_t send_cnt;
33+
atomic64_t recv_cnt;
34+
atomic64_t send_busy_cnt;
35+
atomic64_t err_bd_cnt;
36+
};
37+
3138
struct hisi_zip_ctrl;
3239

3340
struct hisi_zip {
3441
struct hisi_qm qm;
3542
struct list_head list;
3643
struct hisi_zip_ctrl *ctrl;
44+
struct hisi_zip_dfx dfx;
3745
};
3846

3947
struct hisi_zip_sqe {

drivers/crypto/hisilicon/zip/zip_crypto.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,19 +332,22 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data)
332332
{
333333
struct hisi_zip_sqe *sqe = data;
334334
struct hisi_zip_qp_ctx *qp_ctx = qp->qp_ctx;
335+
struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx;
335336
struct hisi_zip_req_q *req_q = &qp_ctx->req_q;
336337
struct hisi_zip_req *req = req_q->q + sqe->tag;
337338
struct acomp_req *acomp_req = req->req;
338339
struct device *dev = &qp->qm->pdev->dev;
339340
u32 status, dlen, head_size;
340341
int err = 0;
341342

343+
atomic64_inc(&dfx->recv_cnt);
342344
status = sqe->dw3 & HZIP_BD_STATUS_M;
343345

344346
if (status != 0 && status != HZIP_NC_ERR) {
345347
dev_err(dev, "%scompress fail in qp%u: %u, output: %u\n",
346348
(qp->alg_type == 0) ? "" : "de", qp->qp_id, status,
347349
sqe->produced);
350+
atomic64_inc(&dfx->err_bd_cnt);
348351
err = -EIO;
349352
}
350353
dlen = sqe->produced;
@@ -487,6 +490,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req,
487490
struct hisi_qp *qp = qp_ctx->qp;
488491
struct device *dev = &qp->qm->pdev->dev;
489492
struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool;
493+
struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx;
490494
struct hisi_zip_sqe zip_sqe;
491495
dma_addr_t input;
492496
dma_addr_t output;
@@ -516,9 +520,12 @@ static int hisi_zip_do_work(struct hisi_zip_req *req,
516520
hisi_zip_config_tag(&zip_sqe, req->req_id);
517521

518522
/* send command to start a task */
523+
atomic64_inc(&dfx->send_cnt);
519524
ret = hisi_qp_send(qp, &zip_sqe);
520-
if (ret < 0)
525+
if (ret < 0) {
526+
atomic64_inc(&dfx->send_busy_cnt);
521527
goto err_unmap_output;
528+
}
522529

523530
return -EINPROGRESS;
524531

drivers/crypto/hisilicon/zip/zip_main.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ struct hisi_zip_hw_error {
9999
const char *msg;
100100
};
101101

102+
struct zip_dfx_item {
103+
const char *name;
104+
u32 offset;
105+
};
106+
107+
static struct zip_dfx_item zip_dfx_files[] = {
108+
{"send_cnt", offsetof(struct hisi_zip_dfx, send_cnt)},
109+
{"recv_cnt", offsetof(struct hisi_zip_dfx, recv_cnt)},
110+
{"send_busy_cnt", offsetof(struct hisi_zip_dfx, send_busy_cnt)},
111+
{"err_bd_cnt", offsetof(struct hisi_zip_dfx, err_bd_cnt)},
112+
};
113+
102114
static const struct hisi_zip_hw_error zip_hw_error[] = {
103115
{ .int_msk = BIT(0), .msg = "zip_ecc_1bitt_err" },
104116
{ .int_msk = BIT(1), .msg = "zip_ecc_2bit_err" },
@@ -469,6 +481,27 @@ static const struct file_operations ctrl_debug_fops = {
469481
.write = ctrl_debug_write,
470482
};
471483

484+
485+
static int zip_debugfs_atomic64_set(void *data, u64 val)
486+
{
487+
if (val)
488+
return -EINVAL;
489+
490+
atomic64_set((atomic64_t *)data, 0);
491+
492+
return 0;
493+
}
494+
495+
static int zip_debugfs_atomic64_get(void *data, u64 *val)
496+
{
497+
*val = atomic64_read((atomic64_t *)data);
498+
499+
return 0;
500+
}
501+
502+
DEFINE_DEBUGFS_ATTRIBUTE(zip_atomic64_ops, zip_debugfs_atomic64_get,
503+
zip_debugfs_atomic64_set, "%llu\n");
504+
472505
static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl)
473506
{
474507
struct hisi_zip *hisi_zip = ctrl->hisi_zip;
@@ -500,6 +533,25 @@ static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl)
500533
return 0;
501534
}
502535

536+
static void hisi_zip_dfx_debug_init(struct hisi_qm *qm)
537+
{
538+
struct hisi_zip *zip = container_of(qm, struct hisi_zip, qm);
539+
struct hisi_zip_dfx *dfx = &zip->dfx;
540+
struct dentry *tmp_dir;
541+
void *data;
542+
int i;
543+
544+
tmp_dir = debugfs_create_dir("zip_dfx", qm->debug.debug_root);
545+
for (i = 0; i < ARRAY_SIZE(zip_dfx_files); i++) {
546+
data = (atomic64_t *)((uintptr_t)dfx + zip_dfx_files[i].offset);
547+
debugfs_create_file(zip_dfx_files[i].name,
548+
0644,
549+
tmp_dir,
550+
data,
551+
&zip_atomic64_ops);
552+
}
553+
}
554+
503555
static int hisi_zip_ctrl_debug_init(struct hisi_zip_ctrl *ctrl)
504556
{
505557
int i;
@@ -538,6 +590,8 @@ static int hisi_zip_debugfs_init(struct hisi_zip *hisi_zip)
538590
goto failed_to_create;
539591
}
540592

593+
hisi_zip_dfx_debug_init(qm);
594+
541595
return 0;
542596

543597
failed_to_create:

0 commit comments

Comments
 (0)