Skip to content

Commit 0a3a396

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/qm - add debugfs to the QM state machine
The QM driver uses debugfs to provides the current state of the QM state machine Signed-off-by: Longfang Liu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Reviewed-by: Zhou Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 8502652 commit 0a3a396

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

Documentation/ABI/testing/debugfs-hisi-hpre

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ Date: Apr 2020
8686
8787
Description: Dump the number of failed QM mailbox commands.
8888
Available for both PF and VF, and take no other effect on HPRE.
89+
90+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/status
91+
Date: Apr 2020
92+
93+
Description: Dump the status of the QM.
94+
Four states: initiated, started, stopped and closed.
95+
Available for both PF and VF, and take no other effect on HPRE.

Documentation/ABI/testing/debugfs-hisi-sec

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,10 @@ Date: Apr 2020
7272
7373
Description: Dump the number of failed QM mailbox commands.
7474
Available for both PF and VF, and take no other effect on SEC.
75+
76+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/status
77+
Date: Apr 2020
78+
79+
Description: Dump the status of the QM.
80+
Four states: initiated, started, stopped and closed.
81+
Available for both PF and VF, and take no other effect on SEC.

Documentation/ABI/testing/debugfs-hisi-zip

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,10 @@ Date: Apr 2020
7979
8080
Description: Dump the number of failed QM mailbox commands.
8181
Available for both PF and VF, and take no other effect on ZIP.
82+
83+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/status
84+
Date: Apr 2020
85+
86+
Description: Dump the status of the QM.
87+
Four states: initiated, started, stopped and closed.
88+
Available for both PF and VF, and take no other effect on ZIP.

drivers/crypto/hisilicon/qm.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@
175175
#define QM_SQE_DATA_ALIGN_MASK GENMASK(6, 0)
176176
#define QMC_ALIGN(sz) ALIGN(sz, 32)
177177

178+
#define QM_DBG_READ_LEN 256
178179
#define QM_DBG_TMP_BUF_LEN 22
179180
#define QM_PCI_COMMAND_INVALID ~0
180181

@@ -2268,6 +2269,37 @@ int hisi_qm_stop(struct hisi_qm *qm)
22682269
}
22692270
EXPORT_SYMBOL_GPL(hisi_qm_stop);
22702271

2272+
static ssize_t qm_status_read(struct file *filp, char __user *buffer,
2273+
size_t count, loff_t *pos)
2274+
{
2275+
struct hisi_qm *qm = filp->private_data;
2276+
char buf[QM_DBG_READ_LEN];
2277+
int val, cp_len, len;
2278+
2279+
if (*pos)
2280+
return 0;
2281+
2282+
if (count < QM_DBG_READ_LEN)
2283+
return -ENOSPC;
2284+
2285+
val = atomic_read(&qm->status.flags);
2286+
len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]);
2287+
if (!len)
2288+
return -EFAULT;
2289+
2290+
cp_len = copy_to_user(buffer, buf, len);
2291+
if (cp_len)
2292+
return -EFAULT;
2293+
2294+
return (*pos = len);
2295+
}
2296+
2297+
static const struct file_operations qm_status_fops = {
2298+
.owner = THIS_MODULE,
2299+
.open = simple_open,
2300+
.read = qm_status_read,
2301+
};
2302+
22712303
static int qm_debugfs_atomic64_set(void *data, u64 val)
22722304
{
22732305
if (val)
@@ -2314,6 +2346,8 @@ int hisi_qm_debug_init(struct hisi_qm *qm)
23142346

23152347
debugfs_create_file("qm_regs", 0444, qm->debug.qm_d, qm, &qm_regs_fops);
23162348

2349+
debugfs_create_file("status", 0444, qm->debug.qm_d, qm,
2350+
&qm_status_fops);
23172351
for (i = 0; i < ARRAY_SIZE(qm_dfx_files); i++) {
23182352
data = (atomic64_t *)((uintptr_t)dfx + qm_dfx_files[i].offset);
23192353
debugfs_create_file(qm_dfx_files[i].name,

0 commit comments

Comments
 (0)