drm/rockchip: Don't change hdmi reference clock rate
[drm/drm-misc.git] / drivers / infiniband / hw / bnxt_re / debugfs.c
blob7c47039044ef0e6ff0367ad08584f6878ac18c06
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
2 /*
3 * Copyright (c) 2024, Broadcom. All rights reserved. The term
4 * Broadcom refers to Broadcom Limited and/or its subsidiaries.
6 * Description: Debugfs component of the bnxt_re driver
7 */
9 #include <linux/debugfs.h>
10 #include <linux/pci.h>
11 #include <rdma/ib_addr.h>
13 #include "bnxt_ulp.h"
14 #include "roce_hsi.h"
15 #include "qplib_res.h"
16 #include "qplib_sp.h"
17 #include "qplib_fp.h"
18 #include "qplib_rcfw.h"
19 #include "bnxt_re.h"
20 #include "ib_verbs.h"
21 #include "debugfs.h"
23 static struct dentry *bnxt_re_debugfs_root;
25 static inline const char *bnxt_re_qp_state_str(u8 state)
27 switch (state) {
28 case CMDQ_MODIFY_QP_NEW_STATE_RESET:
29 return "RST";
30 case CMDQ_MODIFY_QP_NEW_STATE_INIT:
31 return "INIT";
32 case CMDQ_MODIFY_QP_NEW_STATE_RTR:
33 return "RTR";
34 case CMDQ_MODIFY_QP_NEW_STATE_RTS:
35 return "RTS";
36 case CMDQ_MODIFY_QP_NEW_STATE_SQE:
37 return "SQER";
38 case CMDQ_MODIFY_QP_NEW_STATE_SQD:
39 return "SQD";
40 case CMDQ_MODIFY_QP_NEW_STATE_ERR:
41 return "ERR";
42 default:
43 return "Invalid QP state";
47 static inline const char *bnxt_re_qp_type_str(u8 type)
49 switch (type) {
50 case CMDQ_CREATE_QP1_TYPE_GSI: return "QP1";
51 case CMDQ_CREATE_QP_TYPE_GSI: return "QP1";
52 case CMDQ_CREATE_QP_TYPE_RC: return "RC";
53 case CMDQ_CREATE_QP_TYPE_UD: return "UD";
54 case CMDQ_CREATE_QP_TYPE_RAW_ETHERTYPE: return "RAW_ETHERTYPE";
55 default: return "Invalid transport type";
59 static ssize_t qp_info_read(struct file *filep,
60 char __user *buffer,
61 size_t count, loff_t *ppos)
63 struct bnxt_re_qp *qp = filep->private_data;
64 char *buf;
65 int len;
67 if (*ppos)
68 return 0;
70 buf = kasprintf(GFP_KERNEL,
71 "QPN\t\t: %d\n"
72 "transport\t: %s\n"
73 "state\t\t: %s\n"
74 "mtu\t\t: %d\n"
75 "timeout\t\t: %d\n"
76 "remote QPN\t: %d\n",
77 qp->qplib_qp.id,
78 bnxt_re_qp_type_str(qp->qplib_qp.type),
79 bnxt_re_qp_state_str(qp->qplib_qp.state),
80 qp->qplib_qp.mtu,
81 qp->qplib_qp.timeout,
82 qp->qplib_qp.dest_qpn);
83 if (!buf)
84 return -ENOMEM;
85 if (count < strlen(buf)) {
86 kfree(buf);
87 return -ENOSPC;
89 len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
90 kfree(buf);
91 return len;
94 static const struct file_operations debugfs_qp_fops = {
95 .owner = THIS_MODULE,
96 .open = simple_open,
97 .read = qp_info_read,
100 void bnxt_re_debug_add_qpinfo(struct bnxt_re_dev *rdev, struct bnxt_re_qp *qp)
102 char resn[32];
104 sprintf(resn, "0x%x", qp->qplib_qp.id);
105 qp->dentry = debugfs_create_file(resn, 0400, rdev->qp_debugfs, qp, &debugfs_qp_fops);
108 void bnxt_re_debug_rem_qpinfo(struct bnxt_re_dev *rdev, struct bnxt_re_qp *qp)
110 debugfs_remove(qp->dentry);
113 void bnxt_re_debugfs_add_pdev(struct bnxt_re_dev *rdev)
115 struct pci_dev *pdev = rdev->en_dev->pdev;
117 rdev->dbg_root = debugfs_create_dir(dev_name(&pdev->dev), bnxt_re_debugfs_root);
119 rdev->qp_debugfs = debugfs_create_dir("QPs", rdev->dbg_root);
122 void bnxt_re_debugfs_rem_pdev(struct bnxt_re_dev *rdev)
124 debugfs_remove_recursive(rdev->qp_debugfs);
126 debugfs_remove_recursive(rdev->dbg_root);
127 rdev->dbg_root = NULL;
130 void bnxt_re_register_debugfs(void)
132 bnxt_re_debugfs_root = debugfs_create_dir("bnxt_re", NULL);
135 void bnxt_re_unregister_debugfs(void)
137 debugfs_remove(bnxt_re_debugfs_root);