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