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 <liulongfang@huawei.com> Signed-off-by: Shukun Tan <tanshukun1@huawei.com> Reviewed-by: Zaibo Xu <xuzaibo@huawei.com> Reviewed-by: Zhou Wang <wangzhou1@hisilicon.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@@ -86,3 +86,29 @@ Contact: linux-crypto@vger.kernel.org
|
|||||||
Description: Dump the status of the QM.
|
Description: Dump the status of the QM.
|
||||||
Four states: initiated, started, stopped and closed.
|
Four states: initiated, started, stopped and closed.
|
||||||
Available for both PF and VF, and take no other effect on ZIP.
|
Available for both PF and VF, and take no other effect on ZIP.
|
||||||
|
|
||||||
|
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/send_cnt
|
||||||
|
Date: Apr 2020
|
||||||
|
Contact: linux-crypto@vger.kernel.org
|
||||||
|
Description: Dump the total number of sent requests.
|
||||||
|
Available for both PF and VF, and take no other effect on ZIP.
|
||||||
|
|
||||||
|
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/recv_cnt
|
||||||
|
Date: Apr 2020
|
||||||
|
Contact: linux-crypto@vger.kernel.org
|
||||||
|
Description: Dump the total number of received requests.
|
||||||
|
Available for both PF and VF, and take no other effect on ZIP.
|
||||||
|
|
||||||
|
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/send_busy_cnt
|
||||||
|
Date: Apr 2020
|
||||||
|
Contact: linux-crypto@vger.kernel.org
|
||||||
|
Description: Dump the total number of requests received
|
||||||
|
with returning busy.
|
||||||
|
Available for both PF and VF, and take no other effect on ZIP.
|
||||||
|
|
||||||
|
What: /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/err_bd_cnt
|
||||||
|
Date: Apr 2020
|
||||||
|
Contact: linux-crypto@vger.kernel.org
|
||||||
|
Description: Dump the total number of BD type error requests
|
||||||
|
to be received.
|
||||||
|
Available for both PF and VF, and take no other effect on ZIP.
|
||||||
|
@@ -28,12 +28,20 @@ enum hisi_zip_error_type {
|
|||||||
HZIP_NC_ERR = 0x0d,
|
HZIP_NC_ERR = 0x0d,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct hisi_zip_dfx {
|
||||||
|
atomic64_t send_cnt;
|
||||||
|
atomic64_t recv_cnt;
|
||||||
|
atomic64_t send_busy_cnt;
|
||||||
|
atomic64_t err_bd_cnt;
|
||||||
|
};
|
||||||
|
|
||||||
struct hisi_zip_ctrl;
|
struct hisi_zip_ctrl;
|
||||||
|
|
||||||
struct hisi_zip {
|
struct hisi_zip {
|
||||||
struct hisi_qm qm;
|
struct hisi_qm qm;
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct hisi_zip_ctrl *ctrl;
|
struct hisi_zip_ctrl *ctrl;
|
||||||
|
struct hisi_zip_dfx dfx;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hisi_zip_sqe {
|
struct hisi_zip_sqe {
|
||||||
|
@@ -332,6 +332,7 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data)
|
|||||||
{
|
{
|
||||||
struct hisi_zip_sqe *sqe = data;
|
struct hisi_zip_sqe *sqe = data;
|
||||||
struct hisi_zip_qp_ctx *qp_ctx = qp->qp_ctx;
|
struct hisi_zip_qp_ctx *qp_ctx = qp->qp_ctx;
|
||||||
|
struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx;
|
||||||
struct hisi_zip_req_q *req_q = &qp_ctx->req_q;
|
struct hisi_zip_req_q *req_q = &qp_ctx->req_q;
|
||||||
struct hisi_zip_req *req = req_q->q + sqe->tag;
|
struct hisi_zip_req *req = req_q->q + sqe->tag;
|
||||||
struct acomp_req *acomp_req = req->req;
|
struct acomp_req *acomp_req = req->req;
|
||||||
@@ -339,12 +340,14 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data)
|
|||||||
u32 status, dlen, head_size;
|
u32 status, dlen, head_size;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
atomic64_inc(&dfx->recv_cnt);
|
||||||
status = sqe->dw3 & HZIP_BD_STATUS_M;
|
status = sqe->dw3 & HZIP_BD_STATUS_M;
|
||||||
|
|
||||||
if (status != 0 && status != HZIP_NC_ERR) {
|
if (status != 0 && status != HZIP_NC_ERR) {
|
||||||
dev_err(dev, "%scompress fail in qp%u: %u, output: %u\n",
|
dev_err(dev, "%scompress fail in qp%u: %u, output: %u\n",
|
||||||
(qp->alg_type == 0) ? "" : "de", qp->qp_id, status,
|
(qp->alg_type == 0) ? "" : "de", qp->qp_id, status,
|
||||||
sqe->produced);
|
sqe->produced);
|
||||||
|
atomic64_inc(&dfx->err_bd_cnt);
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
}
|
}
|
||||||
dlen = sqe->produced;
|
dlen = sqe->produced;
|
||||||
@@ -487,6 +490,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req,
|
|||||||
struct hisi_qp *qp = qp_ctx->qp;
|
struct hisi_qp *qp = qp_ctx->qp;
|
||||||
struct device *dev = &qp->qm->pdev->dev;
|
struct device *dev = &qp->qm->pdev->dev;
|
||||||
struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool;
|
struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool;
|
||||||
|
struct hisi_zip_dfx *dfx = &qp_ctx->zip_dev->dfx;
|
||||||
struct hisi_zip_sqe zip_sqe;
|
struct hisi_zip_sqe zip_sqe;
|
||||||
dma_addr_t input;
|
dma_addr_t input;
|
||||||
dma_addr_t output;
|
dma_addr_t output;
|
||||||
@@ -516,9 +520,12 @@ static int hisi_zip_do_work(struct hisi_zip_req *req,
|
|||||||
hisi_zip_config_tag(&zip_sqe, req->req_id);
|
hisi_zip_config_tag(&zip_sqe, req->req_id);
|
||||||
|
|
||||||
/* send command to start a task */
|
/* send command to start a task */
|
||||||
|
atomic64_inc(&dfx->send_cnt);
|
||||||
ret = hisi_qp_send(qp, &zip_sqe);
|
ret = hisi_qp_send(qp, &zip_sqe);
|
||||||
if (ret < 0)
|
if (ret < 0) {
|
||||||
|
atomic64_inc(&dfx->send_busy_cnt);
|
||||||
goto err_unmap_output;
|
goto err_unmap_output;
|
||||||
|
}
|
||||||
|
|
||||||
return -EINPROGRESS;
|
return -EINPROGRESS;
|
||||||
|
|
||||||
|
@@ -99,6 +99,18 @@ struct hisi_zip_hw_error {
|
|||||||
const char *msg;
|
const char *msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct zip_dfx_item {
|
||||||
|
const char *name;
|
||||||
|
u32 offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct zip_dfx_item zip_dfx_files[] = {
|
||||||
|
{"send_cnt", offsetof(struct hisi_zip_dfx, send_cnt)},
|
||||||
|
{"recv_cnt", offsetof(struct hisi_zip_dfx, recv_cnt)},
|
||||||
|
{"send_busy_cnt", offsetof(struct hisi_zip_dfx, send_busy_cnt)},
|
||||||
|
{"err_bd_cnt", offsetof(struct hisi_zip_dfx, err_bd_cnt)},
|
||||||
|
};
|
||||||
|
|
||||||
static const struct hisi_zip_hw_error zip_hw_error[] = {
|
static const struct hisi_zip_hw_error zip_hw_error[] = {
|
||||||
{ .int_msk = BIT(0), .msg = "zip_ecc_1bitt_err" },
|
{ .int_msk = BIT(0), .msg = "zip_ecc_1bitt_err" },
|
||||||
{ .int_msk = BIT(1), .msg = "zip_ecc_2bit_err" },
|
{ .int_msk = BIT(1), .msg = "zip_ecc_2bit_err" },
|
||||||
@@ -469,6 +481,27 @@ static const struct file_operations ctrl_debug_fops = {
|
|||||||
.write = ctrl_debug_write,
|
.write = ctrl_debug_write,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int zip_debugfs_atomic64_set(void *data, u64 val)
|
||||||
|
{
|
||||||
|
if (val)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
atomic64_set((atomic64_t *)data, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int zip_debugfs_atomic64_get(void *data, u64 *val)
|
||||||
|
{
|
||||||
|
*val = atomic64_read((atomic64_t *)data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_DEBUGFS_ATTRIBUTE(zip_atomic64_ops, zip_debugfs_atomic64_get,
|
||||||
|
zip_debugfs_atomic64_set, "%llu\n");
|
||||||
|
|
||||||
static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl)
|
static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl)
|
||||||
{
|
{
|
||||||
struct hisi_zip *hisi_zip = ctrl->hisi_zip;
|
struct hisi_zip *hisi_zip = ctrl->hisi_zip;
|
||||||
@@ -500,6 +533,25 @@ static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hisi_zip_dfx_debug_init(struct hisi_qm *qm)
|
||||||
|
{
|
||||||
|
struct hisi_zip *zip = container_of(qm, struct hisi_zip, qm);
|
||||||
|
struct hisi_zip_dfx *dfx = &zip->dfx;
|
||||||
|
struct dentry *tmp_dir;
|
||||||
|
void *data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
tmp_dir = debugfs_create_dir("zip_dfx", qm->debug.debug_root);
|
||||||
|
for (i = 0; i < ARRAY_SIZE(zip_dfx_files); i++) {
|
||||||
|
data = (atomic64_t *)((uintptr_t)dfx + zip_dfx_files[i].offset);
|
||||||
|
debugfs_create_file(zip_dfx_files[i].name,
|
||||||
|
0644,
|
||||||
|
tmp_dir,
|
||||||
|
data,
|
||||||
|
&zip_atomic64_ops);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int hisi_zip_ctrl_debug_init(struct hisi_zip_ctrl *ctrl)
|
static int hisi_zip_ctrl_debug_init(struct hisi_zip_ctrl *ctrl)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -538,6 +590,8 @@ static int hisi_zip_debugfs_init(struct hisi_zip *hisi_zip)
|
|||||||
goto failed_to_create;
|
goto failed_to_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hisi_zip_dfx_debug_init(qm);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
failed_to_create:
|
failed_to_create:
|
||||||
|
Reference in New Issue
Block a user