| 1 | |
| 2 |
|
| 3 |
|
| 4 | #include <linux/pci.h>
|
| 5 |
|
| 6 | #include "core.h"
|
| 7 |
|
| 8 | static struct dentry *pdsc_dir;
|
| 9 |
|
| 10 | void pdsc_debugfs_create(void)
|
| 11 | {
|
| 12 | pdsc_dir = debugfs_create_dir(PDS_CORE_DRV_NAME, NULL);
|
| 13 | }
|
| 14 |
|
| 15 | void pdsc_debugfs_destroy(void)
|
| 16 | {
|
| 17 | debugfs_remove_recursive(pdsc_dir);
|
| 18 | }
|
| 19 |
|
| 20 | void pdsc_debugfs_add_dev(struct pdsc *pdsc)
|
| 21 | {
|
| 22 | pdsc->dentry = debugfs_create_dir(pci_name(pdsc->pdev), pdsc_dir);
|
| 23 |
|
| 24 | debugfs_create_ulong("state", 0400, pdsc->dentry, &pdsc->state);
|
| 25 | }
|
| 26 |
|
| 27 | void pdsc_debugfs_del_dev(struct pdsc *pdsc)
|
| 28 | {
|
| 29 | debugfs_remove_recursive(pdsc->dentry);
|
| 30 | pdsc->dentry = NULL;
|
| 31 | }
|
| 32 |
|
| 33 | static int identity_show(struct seq_file *seq, void *v)
|
| 34 | {
|
| 35 | struct pds_core_dev_identity *ident;
|
| 36 | struct pdsc *pdsc = seq->private;
|
| 37 | int vt;
|
| 38 |
|
| 39 | ident = &pdsc->dev_ident;
|
| 40 |
|
| 41 | seq_printf(seq, "fw_heartbeat: 0x%x\n",
|
| 42 | ioread32(&pdsc->info_regs->fw_heartbeat));
|
| 43 |
|
| 44 | seq_printf(seq, "nlifs: %d\n",
|
| 45 | le32_to_cpu(ident->nlifs));
|
| 46 | seq_printf(seq, "nintrs: %d\n",
|
| 47 | le32_to_cpu(ident->nintrs));
|
| 48 | seq_printf(seq, "ndbpgs_per_lif: %d\n",
|
| 49 | le32_to_cpu(ident->ndbpgs_per_lif));
|
| 50 | seq_printf(seq, "intr_coal_mult: %d\n",
|
| 51 | le32_to_cpu(ident->intr_coal_mult));
|
| 52 | seq_printf(seq, "intr_coal_div: %d\n",
|
| 53 | le32_to_cpu(ident->intr_coal_div));
|
| 54 |
|
| 55 | seq_puts(seq, "vif_types: ");
|
| 56 | for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++)
|
| 57 | seq_printf(seq, "%d ",
|
| 58 | le16_to_cpu(pdsc->dev_ident.vif_types[vt]));
|
| 59 | seq_puts(seq, "\n");
|
| 60 |
|
| 61 | return 0;
|
| 62 | }
|
| 63 | DEFINE_SHOW_ATTRIBUTE(identity);
|
| 64 |
|
| 65 | void pdsc_debugfs_add_ident(struct pdsc *pdsc)
|
| 66 | {
|
| 67 | struct dentry *dentry;
|
| 68 |
|
| 69 |
|
| 70 | dentry = debugfs_lookup("identity", pdsc->dentry);
|
| 71 | if (!IS_ERR_OR_NULL(dentry)) {
|
| 72 | dput(dentry);
|
| 73 | return;
|
| 74 | }
|
| 75 |
|
| 76 | debugfs_create_file("identity", 0400, pdsc->dentry,
|
| 77 | pdsc, &identity_fops);
|
| 78 | }
|
| 79 |
|
| 80 | static int viftype_show(struct seq_file *seq, void *v)
|
| 81 | {
|
| 82 | struct pdsc *pdsc = seq->private;
|
| 83 | int vt;
|
| 84 |
|
| 85 | for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++) {
|
| 86 | if (!pdsc->viftype_status[vt].name)
|
| 87 | continue;
|
| 88 |
|
| 89 | seq_printf(seq, "%s\t%d supported %d enabled\n",
|
| 90 | pdsc->viftype_status[vt].name,
|
| 91 | pdsc->viftype_status[vt].supported,
|
| 92 | pdsc->viftype_status[vt].enabled);
|
| 93 | }
|
| 94 | return 0;
|
| 95 | }
|
| 96 | DEFINE_SHOW_ATTRIBUTE(viftype);
|
| 97 |
|
| 98 | void pdsc_debugfs_add_viftype(struct pdsc *pdsc)
|
| 99 | {
|
| 100 | debugfs_create_file("viftypes", 0400, pdsc->dentry,
|
| 101 | pdsc, &viftype_fops);
|
| 102 | }
|
| 103 |
|
| 104 | static const struct debugfs_reg32 intr_ctrl_regs[] = {
|
| 105 | { .name = "coal_init", .offset = 0, },
|
| 106 | { .name = "mask", .offset = 4, },
|
| 107 | { .name = "credits", .offset = 8, },
|
| 108 | { .name = "mask_on_assert", .offset = 12, },
|
| 109 | { .name = "coal_timer", .offset = 16, },
|
| 110 | };
|
| 111 |
|
| 112 | void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)
|
| 113 | {
|
| 114 | struct dentry *qcq_dentry, *q_dentry, *cq_dentry, *intr_dentry;
|
| 115 | struct debugfs_regset32 *intr_ctrl_regset;
|
| 116 | struct pdsc_queue *q = &qcq->q;
|
| 117 | struct pdsc_cq *cq = &qcq->cq;
|
| 118 |
|
| 119 | qcq_dentry = debugfs_create_dir(q->name, pdsc->dentry);
|
| 120 | if (IS_ERR(qcq_dentry))
|
| 121 | return;
|
| 122 | qcq->dentry = qcq_dentry;
|
| 123 |
|
| 124 | debugfs_create_x64("q_base_pa", 0400, qcq_dentry, &qcq->q_base_pa);
|
| 125 | debugfs_create_x32("q_size", 0400, qcq_dentry, &qcq->q_size);
|
| 126 | debugfs_create_x64("cq_base_pa", 0400, qcq_dentry, &qcq->cq_base_pa);
|
| 127 | debugfs_create_x32("cq_size", 0400, qcq_dentry, &qcq->cq_size);
|
| 128 | debugfs_create_x32("accum_work", 0400, qcq_dentry, &qcq->accum_work);
|
| 129 |
|
| 130 | q_dentry = debugfs_create_dir("q", qcq->dentry);
|
| 131 | if (IS_ERR(q_dentry))
|
| 132 | return;
|
| 133 |
|
| 134 | debugfs_create_u32("index", 0400, q_dentry, &q->index);
|
| 135 | debugfs_create_u32("num_descs", 0400, q_dentry, &q->num_descs);
|
| 136 | debugfs_create_u32("desc_size", 0400, q_dentry, &q->desc_size);
|
| 137 | debugfs_create_u32("pid", 0400, q_dentry, &q->pid);
|
| 138 |
|
| 139 | debugfs_create_u16("tail", 0400, q_dentry, &q->tail_idx);
|
| 140 | debugfs_create_u16("head", 0400, q_dentry, &q->head_idx);
|
| 141 |
|
| 142 | cq_dentry = debugfs_create_dir("cq", qcq->dentry);
|
| 143 | if (IS_ERR(cq_dentry))
|
| 144 | return;
|
| 145 |
|
| 146 | debugfs_create_x64("base_pa", 0400, cq_dentry, &cq->base_pa);
|
| 147 | debugfs_create_u32("num_descs", 0400, cq_dentry, &cq->num_descs);
|
| 148 | debugfs_create_u32("desc_size", 0400, cq_dentry, &cq->desc_size);
|
| 149 | debugfs_create_bool("done_color", 0400, cq_dentry, &cq->done_color);
|
| 150 | debugfs_create_u16("tail", 0400, cq_dentry, &cq->tail_idx);
|
| 151 |
|
| 152 | if (qcq->flags & PDS_CORE_QCQ_F_INTR) {
|
| 153 | struct pdsc_intr_info *intr = &pdsc->intr_info[qcq->intx];
|
| 154 |
|
| 155 | intr_dentry = debugfs_create_dir("intr", qcq->dentry);
|
| 156 | if (IS_ERR(intr_dentry))
|
| 157 | return;
|
| 158 |
|
| 159 | debugfs_create_u32("index", 0400, intr_dentry, &intr->index);
|
| 160 | debugfs_create_u32("vector", 0400, intr_dentry, &intr->vector);
|
| 161 |
|
| 162 | intr_ctrl_regset = devm_kzalloc(pdsc->dev,
|
| 163 | sizeof(*intr_ctrl_regset),
|
| 164 | GFP_KERNEL);
|
| 165 | if (!intr_ctrl_regset)
|
| 166 | return;
|
| 167 | intr_ctrl_regset->regs = intr_ctrl_regs;
|
| 168 | intr_ctrl_regset->nregs = ARRAY_SIZE(intr_ctrl_regs);
|
| 169 | intr_ctrl_regset->base = &pdsc->intr_ctrl[intr->index];
|
| 170 |
|
| 171 | debugfs_create_regset32("intr_ctrl", 0400, intr_dentry,
|
| 172 | intr_ctrl_regset);
|
| 173 | }
|
| 174 | };
|
| 175 |
|
| 176 | void pdsc_debugfs_del_qcq(struct pdsc_qcq *qcq)
|
| 177 | {
|
| 178 | debugfs_remove_recursive(qcq->dentry);
|
| 179 | qcq->dentry = NULL;
|
| 180 | }
|
| 181 |
|
| 182 | static int host_mem_show(struct seq_file *seq, void *v)
|
| 183 | {
|
| 184 | struct pdsc *pdsc = seq->private;
|
| 185 | struct pdsc_host_mem *hm;
|
| 186 | int i;
|
| 187 |
|
| 188 | if (!pdsc->host_mem_reqs || pdsc->num_host_mem_reqs == 0) {
|
| 189 | seq_puts(seq, "No host memory allocated\n");
|
| 190 | return 0;
|
| 191 | }
|
| 192 |
|
| 193 | seq_printf(seq, "Host memory requests: %u\n\n",
|
| 194 | pdsc->num_host_mem_reqs);
|
| 195 | seq_puts(seq, "Tag Size Order PA\n");
|
| 196 | seq_puts(seq, "--- ---- ----- --\n");
|
| 197 |
|
| 198 | for (i = 0; i < pdsc->num_host_mem_reqs; i++) {
|
| 199 | hm = &pdsc->host_mem_reqs[i];
|
| 200 |
|
| 201 | if (!hm->pg)
|
| 202 | continue;
|
| 203 |
|
| 204 | seq_printf(seq, "%-6u %-12u %-6u %pad\n",
|
| 205 | hm->tag, hm->size, hm->order, &hm->pa);
|
| 206 | }
|
| 207 |
|
| 208 | return 0;
|
| 209 | }
|
| 210 | DEFINE_SHOW_ATTRIBUTE(host_mem);
|
| 211 |
|
| 212 | void pdsc_debugfs_add_host_mem(struct pdsc *pdsc)
|
| 213 | {
|
| 214 | if (!(pdsc->dev_ident.capabilities &
|
| 215 | cpu_to_le64(PDS_CORE_DEV_CAP_HOST_MEM)))
|
| 216 | return;
|
| 217 |
|
| 218 | debugfs_create_file("host_mem", 0400, pdsc->dentry,
|
| 219 | pdsc, &host_mem_fops);
|
| 220 | }
|
| 221 |
|
| 222 | void pdsc_debugfs_del_host_mem(struct pdsc *pdsc)
|
| 223 | {
|
| 224 | debugfs_lookup_and_remove("host_mem", pdsc->dentry);
|
| 225 | }
|