^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright 2019 NXP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include "compat.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "debugfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "regs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "intern.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static int caam_debugfs_u64_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *val = caam64_to_cpu(*(u64 *)data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) static int caam_debugfs_u32_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *val = caam32_to_cpu(*(u32 *)data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #ifdef CONFIG_CAAM_QI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * This is a counter for the number of times the congestion group (where all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * the request and response queueus are) reached congestion. Incremented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * each time the congestion callback is called with congested == true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static u64 times_congested;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) void caam_debugfs_qi_congested(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) times_congested++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) void caam_debugfs_qi_init(struct caam_drv_private *ctrlpriv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) debugfs_create_file("qi_congested", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) ×_congested, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) void caam_debugfs_init(struct caam_drv_private *ctrlpriv, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct caam_perfmon *perfmon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * FIXME: needs better naming distinction, as some amalgamation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * "caam" and nprop->full_name. The OF name isn't distinctive,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * but does separate instances
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) perfmon = (struct caam_perfmon __force *)&ctrlpriv->ctrl->perfmon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) ctrlpriv->ctl = debugfs_create_dir("ctl", root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) debugfs_create_file("rq_dequeued", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) &perfmon->req_dequeued, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) debugfs_create_file("ob_rq_encrypted", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) &perfmon->ob_enc_req, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) debugfs_create_file("ib_rq_decrypted", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) &perfmon->ib_dec_req, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) debugfs_create_file("ob_bytes_encrypted", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) &perfmon->ob_enc_bytes, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) debugfs_create_file("ob_bytes_protected", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) &perfmon->ob_prot_bytes, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) debugfs_create_file("ib_bytes_decrypted", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) &perfmon->ib_dec_bytes, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) debugfs_create_file("ib_bytes_validated", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) &perfmon->ib_valid_bytes, &caam_fops_u64_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /* Controller level - global status values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) debugfs_create_file("fault_addr", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) &perfmon->faultaddr, &caam_fops_u32_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) debugfs_create_file("fault_detail", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) &perfmon->faultdetail, &caam_fops_u32_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) debugfs_create_file("fault_status", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) &perfmon->status, &caam_fops_u32_ro);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* Internal covering keys (useful in non-secure mode only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ctrlpriv->ctl_kek_wrap.data = (__force void *)&ctrlpriv->ctrl->kek[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) ctrlpriv->ctl_kek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) debugfs_create_blob("kek", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) &ctrlpriv->ctl_kek_wrap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) ctrlpriv->ctl_tkek_wrap.data = (__force void *)&ctrlpriv->ctrl->tkek[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ctrlpriv->ctl_tkek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) debugfs_create_blob("tkek", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) &ctrlpriv->ctl_tkek_wrap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) ctrlpriv->ctl_tdsk_wrap.data = (__force void *)&ctrlpriv->ctrl->tdsk[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ctrlpriv->ctl_tdsk_wrap.size = KEK_KEY_SIZE * sizeof(u32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) debugfs_create_blob("tdsk", 0444, ctrlpriv->ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) &ctrlpriv->ctl_tdsk_wrap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }