2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2013 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2, as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Intel MIC Host driver.
21 #include <linux/debugfs.h>
22 #include <linux/pci.h>
23 #include <linux/seq_file.h>
25 #include <linux/mic_common.h>
26 #include "../common/mic_dev.h"
27 #include "mic_device.h"
30 /* Debugfs parent dir */
31 static struct dentry *mic_dbg;
33 static int mic_smpt_show(struct seq_file *s, void *pos)
36 struct mic_device *mdev = s->private;
39 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
40 mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
41 seq_puts(s, "====================================================\n");
44 struct mic_smpt_info *smpt_info = mdev->smpt;
45 spin_lock_irqsave(&smpt_info->smpt_lock, flags);
46 for (i = 0; i < smpt_info->info.num_reg; i++) {
47 seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
48 " ", i, smpt_info->entry[i].dma_addr,
49 smpt_info->entry[i].ref_count);
51 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
53 seq_puts(s, "====================================================\n");
57 DEFINE_SHOW_ATTRIBUTE(mic_smpt);
59 static int mic_post_code_show(struct seq_file *s, void *pos)
61 struct mic_device *mdev = s->private;
62 u32 reg = mdev->ops->get_postcode(mdev);
64 seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff);
68 DEFINE_SHOW_ATTRIBUTE(mic_post_code);
70 static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
72 struct mic_device *mdev = s->private;
77 struct pci_dev *pdev = mdev->pdev;
79 if (pci_dev_msi_enabled(pdev)) {
80 for (i = 0; i < mdev->irq_info.num_vectors; i++) {
81 if (pdev->msix_enabled) {
82 entry = mdev->irq_info.msix_entries[i].entry;
83 vector = mdev->irq_info.msix_entries[i].vector;
89 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
91 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
92 "IRQ:", vector, "Entry:", entry, i, reg);
94 seq_printf(s, "%-10s", "offset:");
95 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
96 seq_printf(s, "%4d ", j);
100 seq_printf(s, "%-10s", "count:");
101 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
102 seq_printf(s, "%4d ",
103 (mdev->irq_info.mic_msi_map[i] &
108 seq_puts(s, "MSI/MSIx interrupts not enabled\n");
114 DEFINE_SHOW_ATTRIBUTE(mic_msi_irq_info);
117 * mic_create_debug_dir - Initialize MIC debugfs entries.
119 void mic_create_debug_dir(struct mic_device *mdev)
126 scnprintf(name, sizeof(name), "mic%d", mdev->id);
127 mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
131 debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
134 debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
135 &mic_post_code_fops);
137 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
138 &mic_msi_irq_info_fops);
142 * mic_delete_debug_dir - Uninitialize MIC debugfs entries.
144 void mic_delete_debug_dir(struct mic_device *mdev)
149 debugfs_remove_recursive(mdev->dbg_dir);
153 * mic_init_debugfs - Initialize global debugfs entry.
155 void __init mic_init_debugfs(void)
157 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
159 pr_err("can't create debugfs dir\n");
163 * mic_exit_debugfs - Uninitialize global debugfs entry
165 void mic_exit_debugfs(void)
167 debugfs_remove(mic_dbg);