18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * AMD Cryptographic Coprocessor (CCP) driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2017 Advanced Micro Devices, Inc.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Author: Gary R Hook <gary.hook@amd.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/debugfs.h>
118c2ecf20Sopenharmony_ci#include <linux/ccp.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include "ccp-dev.h"
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/* DebugFS helpers */
168c2ecf20Sopenharmony_ci#define	OBUFP		(obuf + oboff)
178c2ecf20Sopenharmony_ci#define	OBUFLEN		512
188c2ecf20Sopenharmony_ci#define	OBUFSPC		(OBUFLEN - oboff)
198c2ecf20Sopenharmony_ci#define	OSCNPRINTF(fmt, ...) \
208c2ecf20Sopenharmony_ci		scnprintf(OBUFP, OBUFSPC, fmt, ## __VA_ARGS__)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define BUFLEN	63
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci#define	RI_VERSION_NUM	0x0000003F
258c2ecf20Sopenharmony_ci#define	RI_AES_PRESENT	0x00000040
268c2ecf20Sopenharmony_ci#define	RI_3DES_PRESENT	0x00000080
278c2ecf20Sopenharmony_ci#define	RI_SHA_PRESENT	0x00000100
288c2ecf20Sopenharmony_ci#define	RI_RSA_PRESENT	0x00000200
298c2ecf20Sopenharmony_ci#define	RI_ECC_PRESENT	0x00000400
308c2ecf20Sopenharmony_ci#define	RI_ZDE_PRESENT	0x00000800
318c2ecf20Sopenharmony_ci#define	RI_ZCE_PRESENT	0x00001000
328c2ecf20Sopenharmony_ci#define	RI_TRNG_PRESENT	0x00002000
338c2ecf20Sopenharmony_ci#define	RI_ELFC_PRESENT	0x00004000
348c2ecf20Sopenharmony_ci#define	RI_ELFC_SHIFT	14
358c2ecf20Sopenharmony_ci#define	RI_NUM_VQM	0x00078000
368c2ecf20Sopenharmony_ci#define	RI_NVQM_SHIFT	15
378c2ecf20Sopenharmony_ci#define	RI_NVQM(r)	(((r) * RI_NUM_VQM) >> RI_NVQM_SHIFT)
388c2ecf20Sopenharmony_ci#define	RI_LSB_ENTRIES	0x0FF80000
398c2ecf20Sopenharmony_ci#define	RI_NLSB_SHIFT	19
408c2ecf20Sopenharmony_ci#define	RI_NLSB(r)	(((r) * RI_LSB_ENTRIES) >> RI_NLSB_SHIFT)
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_cistatic ssize_t ccp5_debugfs_info_read(struct file *filp, char __user *ubuf,
438c2ecf20Sopenharmony_ci				      size_t count, loff_t *offp)
448c2ecf20Sopenharmony_ci{
458c2ecf20Sopenharmony_ci	struct ccp_device *ccp = filp->private_data;
468c2ecf20Sopenharmony_ci	unsigned int oboff = 0;
478c2ecf20Sopenharmony_ci	unsigned int regval;
488c2ecf20Sopenharmony_ci	ssize_t ret;
498c2ecf20Sopenharmony_ci	char *obuf;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	if (!ccp)
528c2ecf20Sopenharmony_ci		return 0;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	obuf = kmalloc(OBUFLEN, GFP_KERNEL);
558c2ecf20Sopenharmony_ci	if (!obuf)
568c2ecf20Sopenharmony_ci		return -ENOMEM;
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("Device name: %s\n", ccp->name);
598c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("   RNG name: %s\n", ccp->rngname);
608c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("   # Queues: %d\n", ccp->cmd_q_count);
618c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("     # Cmds: %d\n", ccp->cmd_count);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	regval = ioread32(ccp->io_regs + CMD5_PSP_CCP_VERSION);
648c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("    Version: %d\n", regval & RI_VERSION_NUM);
658c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("    Engines:");
668c2ecf20Sopenharmony_ci	if (regval & RI_AES_PRESENT)
678c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" AES");
688c2ecf20Sopenharmony_ci	if (regval & RI_3DES_PRESENT)
698c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" 3DES");
708c2ecf20Sopenharmony_ci	if (regval & RI_SHA_PRESENT)
718c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" SHA");
728c2ecf20Sopenharmony_ci	if (regval & RI_RSA_PRESENT)
738c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" RSA");
748c2ecf20Sopenharmony_ci	if (regval & RI_ECC_PRESENT)
758c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" ECC");
768c2ecf20Sopenharmony_ci	if (regval & RI_ZDE_PRESENT)
778c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" ZDE");
788c2ecf20Sopenharmony_ci	if (regval & RI_ZCE_PRESENT)
798c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" ZCE");
808c2ecf20Sopenharmony_ci	if (regval & RI_TRNG_PRESENT)
818c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" TRNG");
828c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("\n");
838c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("     Queues: %d\n",
848c2ecf20Sopenharmony_ci		   (regval & RI_NUM_VQM) >> RI_NVQM_SHIFT);
858c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("LSB Entries: %d\n",
868c2ecf20Sopenharmony_ci		   (regval & RI_LSB_ENTRIES) >> RI_NLSB_SHIFT);
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
898c2ecf20Sopenharmony_ci	kfree(obuf);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	return ret;
928c2ecf20Sopenharmony_ci}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/* Return a formatted buffer containing the current
958c2ecf20Sopenharmony_ci * statistics across all queues for a CCP.
968c2ecf20Sopenharmony_ci */
978c2ecf20Sopenharmony_cistatic ssize_t ccp5_debugfs_stats_read(struct file *filp, char __user *ubuf,
988c2ecf20Sopenharmony_ci				       size_t count, loff_t *offp)
998c2ecf20Sopenharmony_ci{
1008c2ecf20Sopenharmony_ci	struct ccp_device *ccp = filp->private_data;
1018c2ecf20Sopenharmony_ci	unsigned long total_xts_aes_ops = 0;
1028c2ecf20Sopenharmony_ci	unsigned long total_3des_ops = 0;
1038c2ecf20Sopenharmony_ci	unsigned long total_aes_ops = 0;
1048c2ecf20Sopenharmony_ci	unsigned long total_sha_ops = 0;
1058c2ecf20Sopenharmony_ci	unsigned long total_rsa_ops = 0;
1068c2ecf20Sopenharmony_ci	unsigned long total_ecc_ops = 0;
1078c2ecf20Sopenharmony_ci	unsigned long total_pt_ops = 0;
1088c2ecf20Sopenharmony_ci	unsigned long total_ops = 0;
1098c2ecf20Sopenharmony_ci	unsigned int oboff = 0;
1108c2ecf20Sopenharmony_ci	ssize_t ret = 0;
1118c2ecf20Sopenharmony_ci	unsigned int i;
1128c2ecf20Sopenharmony_ci	char *obuf;
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	for (i = 0; i < ccp->cmd_q_count; i++) {
1158c2ecf20Sopenharmony_ci		struct ccp_cmd_queue *cmd_q = &ccp->cmd_q[i];
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci		total_ops += cmd_q->total_ops;
1188c2ecf20Sopenharmony_ci		total_aes_ops += cmd_q->total_aes_ops;
1198c2ecf20Sopenharmony_ci		total_xts_aes_ops += cmd_q->total_xts_aes_ops;
1208c2ecf20Sopenharmony_ci		total_3des_ops += cmd_q->total_3des_ops;
1218c2ecf20Sopenharmony_ci		total_sha_ops += cmd_q->total_sha_ops;
1228c2ecf20Sopenharmony_ci		total_rsa_ops += cmd_q->total_rsa_ops;
1238c2ecf20Sopenharmony_ci		total_pt_ops += cmd_q->total_pt_ops;
1248c2ecf20Sopenharmony_ci		total_ecc_ops += cmd_q->total_ecc_ops;
1258c2ecf20Sopenharmony_ci	}
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	obuf = kmalloc(OBUFLEN, GFP_KERNEL);
1288c2ecf20Sopenharmony_ci	if (!obuf)
1298c2ecf20Sopenharmony_ci		return -ENOMEM;
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("Total Interrupts Handled: %ld\n",
1328c2ecf20Sopenharmony_ci			    ccp->total_interrupts);
1338c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("        Total Operations: %ld\n",
1348c2ecf20Sopenharmony_ci			    total_ops);
1358c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     AES: %ld\n",
1368c2ecf20Sopenharmony_ci			    total_aes_ops);
1378c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                 XTS AES: %ld\n",
1388c2ecf20Sopenharmony_ci			    total_xts_aes_ops);
1398c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     SHA: %ld\n",
1408c2ecf20Sopenharmony_ci			    total_3des_ops);
1418c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     SHA: %ld\n",
1428c2ecf20Sopenharmony_ci			    total_sha_ops);
1438c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     RSA: %ld\n",
1448c2ecf20Sopenharmony_ci			    total_rsa_ops);
1458c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("               Pass-Thru: %ld\n",
1468c2ecf20Sopenharmony_ci			    total_pt_ops);
1478c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     ECC: %ld\n",
1488c2ecf20Sopenharmony_ci			    total_ecc_ops);
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
1518c2ecf20Sopenharmony_ci	kfree(obuf);
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci	return ret;
1548c2ecf20Sopenharmony_ci}
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/* Reset the counters in a queue
1578c2ecf20Sopenharmony_ci */
1588c2ecf20Sopenharmony_cistatic void ccp5_debugfs_reset_queue_stats(struct ccp_cmd_queue *cmd_q)
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci	cmd_q->total_ops = 0L;
1618c2ecf20Sopenharmony_ci	cmd_q->total_aes_ops = 0L;
1628c2ecf20Sopenharmony_ci	cmd_q->total_xts_aes_ops = 0L;
1638c2ecf20Sopenharmony_ci	cmd_q->total_3des_ops = 0L;
1648c2ecf20Sopenharmony_ci	cmd_q->total_sha_ops = 0L;
1658c2ecf20Sopenharmony_ci	cmd_q->total_rsa_ops = 0L;
1668c2ecf20Sopenharmony_ci	cmd_q->total_pt_ops = 0L;
1678c2ecf20Sopenharmony_ci	cmd_q->total_ecc_ops = 0L;
1688c2ecf20Sopenharmony_ci}
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/* A value was written to the stats variable, which
1718c2ecf20Sopenharmony_ci * should be used to reset the queue counters across
1728c2ecf20Sopenharmony_ci * that device.
1738c2ecf20Sopenharmony_ci */
1748c2ecf20Sopenharmony_cistatic ssize_t ccp5_debugfs_stats_write(struct file *filp,
1758c2ecf20Sopenharmony_ci					const char __user *ubuf,
1768c2ecf20Sopenharmony_ci					size_t count, loff_t *offp)
1778c2ecf20Sopenharmony_ci{
1788c2ecf20Sopenharmony_ci	struct ccp_device *ccp = filp->private_data;
1798c2ecf20Sopenharmony_ci	int i;
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	for (i = 0; i < ccp->cmd_q_count; i++)
1828c2ecf20Sopenharmony_ci		ccp5_debugfs_reset_queue_stats(&ccp->cmd_q[i]);
1838c2ecf20Sopenharmony_ci	ccp->total_interrupts = 0L;
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	return count;
1868c2ecf20Sopenharmony_ci}
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* Return a formatted buffer containing the current information
1898c2ecf20Sopenharmony_ci * for that queue
1908c2ecf20Sopenharmony_ci */
1918c2ecf20Sopenharmony_cistatic ssize_t ccp5_debugfs_queue_read(struct file *filp, char __user *ubuf,
1928c2ecf20Sopenharmony_ci				       size_t count, loff_t *offp)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	struct ccp_cmd_queue *cmd_q = filp->private_data;
1958c2ecf20Sopenharmony_ci	unsigned int oboff = 0;
1968c2ecf20Sopenharmony_ci	unsigned int regval;
1978c2ecf20Sopenharmony_ci	ssize_t ret;
1988c2ecf20Sopenharmony_ci	char *obuf;
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	if (!cmd_q)
2018c2ecf20Sopenharmony_ci		return 0;
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci	obuf = kmalloc(OBUFLEN, GFP_KERNEL);
2048c2ecf20Sopenharmony_ci	if (!obuf)
2058c2ecf20Sopenharmony_ci		return -ENOMEM;
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("  Total Queue Operations: %ld\n",
2088c2ecf20Sopenharmony_ci			    cmd_q->total_ops);
2098c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     AES: %ld\n",
2108c2ecf20Sopenharmony_ci			    cmd_q->total_aes_ops);
2118c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                 XTS AES: %ld\n",
2128c2ecf20Sopenharmony_ci			    cmd_q->total_xts_aes_ops);
2138c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     SHA: %ld\n",
2148c2ecf20Sopenharmony_ci			    cmd_q->total_3des_ops);
2158c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     SHA: %ld\n",
2168c2ecf20Sopenharmony_ci			    cmd_q->total_sha_ops);
2178c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     RSA: %ld\n",
2188c2ecf20Sopenharmony_ci			    cmd_q->total_rsa_ops);
2198c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("               Pass-Thru: %ld\n",
2208c2ecf20Sopenharmony_ci			    cmd_q->total_pt_ops);
2218c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("                     ECC: %ld\n",
2228c2ecf20Sopenharmony_ci			    cmd_q->total_ecc_ops);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	regval = ioread32(cmd_q->reg_int_enable);
2258c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("      Enabled Interrupts:");
2268c2ecf20Sopenharmony_ci	if (regval & INT_EMPTY_QUEUE)
2278c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" EMPTY");
2288c2ecf20Sopenharmony_ci	if (regval & INT_QUEUE_STOPPED)
2298c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" STOPPED");
2308c2ecf20Sopenharmony_ci	if (regval & INT_ERROR)
2318c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" ERROR");
2328c2ecf20Sopenharmony_ci	if (regval & INT_COMPLETION)
2338c2ecf20Sopenharmony_ci		oboff += OSCNPRINTF(" COMPLETION");
2348c2ecf20Sopenharmony_ci	oboff += OSCNPRINTF("\n");
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
2378c2ecf20Sopenharmony_ci	kfree(obuf);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	return ret;
2408c2ecf20Sopenharmony_ci}
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci/* A value was written to the stats variable for a
2438c2ecf20Sopenharmony_ci * queue. Reset the queue counters to this value.
2448c2ecf20Sopenharmony_ci */
2458c2ecf20Sopenharmony_cistatic ssize_t ccp5_debugfs_queue_write(struct file *filp,
2468c2ecf20Sopenharmony_ci					const char __user *ubuf,
2478c2ecf20Sopenharmony_ci					size_t count, loff_t *offp)
2488c2ecf20Sopenharmony_ci{
2498c2ecf20Sopenharmony_ci	struct ccp_cmd_queue *cmd_q = filp->private_data;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	ccp5_debugfs_reset_queue_stats(cmd_q);
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	return count;
2548c2ecf20Sopenharmony_ci}
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_cistatic const struct file_operations ccp_debugfs_info_ops = {
2578c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
2588c2ecf20Sopenharmony_ci	.open = simple_open,
2598c2ecf20Sopenharmony_ci	.read = ccp5_debugfs_info_read,
2608c2ecf20Sopenharmony_ci	.write = NULL,
2618c2ecf20Sopenharmony_ci};
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_cistatic const struct file_operations ccp_debugfs_queue_ops = {
2648c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
2658c2ecf20Sopenharmony_ci	.open = simple_open,
2668c2ecf20Sopenharmony_ci	.read = ccp5_debugfs_queue_read,
2678c2ecf20Sopenharmony_ci	.write = ccp5_debugfs_queue_write,
2688c2ecf20Sopenharmony_ci};
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_cistatic const struct file_operations ccp_debugfs_stats_ops = {
2718c2ecf20Sopenharmony_ci	.owner = THIS_MODULE,
2728c2ecf20Sopenharmony_ci	.open = simple_open,
2738c2ecf20Sopenharmony_ci	.read = ccp5_debugfs_stats_read,
2748c2ecf20Sopenharmony_ci	.write = ccp5_debugfs_stats_write,
2758c2ecf20Sopenharmony_ci};
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistatic struct dentry *ccp_debugfs_dir;
2788c2ecf20Sopenharmony_cistatic DEFINE_MUTEX(ccp_debugfs_lock);
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci#define	MAX_NAME_LEN	20
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_civoid ccp5_debugfs_setup(struct ccp_device *ccp)
2838c2ecf20Sopenharmony_ci{
2848c2ecf20Sopenharmony_ci	struct ccp_cmd_queue *cmd_q;
2858c2ecf20Sopenharmony_ci	char name[MAX_NAME_LEN + 1];
2868c2ecf20Sopenharmony_ci	struct dentry *debugfs_q_instance;
2878c2ecf20Sopenharmony_ci	int i;
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_ci	if (!debugfs_initialized())
2908c2ecf20Sopenharmony_ci		return;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci	mutex_lock(&ccp_debugfs_lock);
2938c2ecf20Sopenharmony_ci	if (!ccp_debugfs_dir)
2948c2ecf20Sopenharmony_ci		ccp_debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL);
2958c2ecf20Sopenharmony_ci	mutex_unlock(&ccp_debugfs_lock);
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci	ccp->debugfs_instance = debugfs_create_dir(ccp->name, ccp_debugfs_dir);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	debugfs_create_file("info", 0400, ccp->debugfs_instance, ccp,
3008c2ecf20Sopenharmony_ci			    &ccp_debugfs_info_ops);
3018c2ecf20Sopenharmony_ci
3028c2ecf20Sopenharmony_ci	debugfs_create_file("stats", 0600, ccp->debugfs_instance, ccp,
3038c2ecf20Sopenharmony_ci			    &ccp_debugfs_stats_ops);
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	for (i = 0; i < ccp->cmd_q_count; i++) {
3068c2ecf20Sopenharmony_ci		cmd_q = &ccp->cmd_q[i];
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci		snprintf(name, MAX_NAME_LEN - 1, "q%d", cmd_q->id);
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci		debugfs_q_instance =
3118c2ecf20Sopenharmony_ci			debugfs_create_dir(name, ccp->debugfs_instance);
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci		debugfs_create_file("stats", 0600, debugfs_q_instance, cmd_q,
3148c2ecf20Sopenharmony_ci				    &ccp_debugfs_queue_ops);
3158c2ecf20Sopenharmony_ci	}
3168c2ecf20Sopenharmony_ci
3178c2ecf20Sopenharmony_ci	return;
3188c2ecf20Sopenharmony_ci}
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_civoid ccp5_debugfs_destroy(void)
3218c2ecf20Sopenharmony_ci{
3228c2ecf20Sopenharmony_ci	debugfs_remove_recursive(ccp_debugfs_dir);
3238c2ecf20Sopenharmony_ci}
324