2 * Intel MIC Platform Software Stack (MPSS)
4 * Copyright(c) 2014 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.
18 #include <linux/debugfs.h>
19 #include <linux/seq_file.h>
21 #include "../common/mic_dev.h"
22 #include "scif_main.h"
24 /* Debugfs parent dir */
25 static struct dentry *scif_dbg;
27 static int scif_dev_show(struct seq_file *s, void *unused)
31 seq_printf(s, "Total Nodes %d Self Node Id %d Maxid %d\n",
32 scif_info.total, scif_info.nodeid,
38 seq_printf(s, "%-16s\t%-16s\n", "node_id", "state");
40 for (node = 0; node <= scif_info.maxid; node++)
41 seq_printf(s, "%-16d\t%-16s\n", scif_dev[node].node,
42 _scifdev_alive(&scif_dev[node]) ?
43 "Running" : "Offline");
47 DEFINE_SHOW_ATTRIBUTE(scif_dev);
49 static void scif_display_window(struct scif_window *window, struct seq_file *s)
52 struct scatterlist *sg;
53 scif_pinned_pages_t pin = window->pinned_pages;
55 seq_printf(s, "window %p type %d temp %d offset 0x%llx ",
56 window, window->type, window->temp, window->offset);
57 seq_printf(s, "nr_pages 0x%llx nr_contig_chunks 0x%x prot %d ",
58 window->nr_pages, window->nr_contig_chunks, window->prot);
59 seq_printf(s, "ref_count %d magic 0x%llx peer_window 0x%llx ",
60 window->ref_count, window->magic, window->peer_window);
61 seq_printf(s, "unreg_state 0x%x va_for_temp 0x%lx\n",
62 window->unreg_state, window->va_for_temp);
64 for (j = 0; j < window->nr_contig_chunks; j++)
65 seq_printf(s, "page[%d] dma_addr 0x%llx num_pages 0x%llx\n", j,
66 window->dma_addr[j], window->num_pages[j]);
68 if (window->type == SCIF_WINDOW_SELF && pin)
69 for (j = 0; j < window->nr_pages; j++)
70 seq_printf(s, "page[%d] = pinned_pages %p address %p\n",
72 page_address(pin->pages[j]));
75 for_each_sg(window->st->sgl, sg, window->st->nents, j)
76 seq_printf(s, "sg[%d] dma addr 0x%llx length 0x%x\n",
77 j, sg_dma_address(sg), sg_dma_len(sg));
80 static void scif_display_all_windows(struct list_head *head, struct seq_file *s)
82 struct list_head *item;
83 struct scif_window *window;
85 list_for_each(item, head) {
86 window = list_entry(item, struct scif_window, list);
87 scif_display_window(window, s);
91 static int scif_rma_show(struct seq_file *s, void *unused)
93 struct scif_endpt *ep;
94 struct list_head *pos;
96 mutex_lock(&scif_info.connlock);
97 list_for_each(pos, &scif_info.connected) {
98 ep = list_entry(pos, struct scif_endpt, list);
99 seq_printf(s, "ep %p self windows\n", ep);
100 mutex_lock(&ep->rma_info.rma_lock);
101 scif_display_all_windows(&ep->rma_info.reg_list, s);
102 seq_printf(s, "ep %p remote windows\n", ep);
103 scif_display_all_windows(&ep->rma_info.remote_reg_list, s);
104 mutex_unlock(&ep->rma_info.rma_lock);
106 mutex_unlock(&scif_info.connlock);
110 DEFINE_SHOW_ATTRIBUTE(scif_rma);
112 void __init scif_init_debugfs(void)
114 scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
116 dev_err(scif_info.mdev.this_device,
117 "can't create debugfs dir scif\n");
121 debugfs_create_file("scif_dev", 0444, scif_dbg, NULL, &scif_dev_fops);
122 debugfs_create_file("scif_rma", 0444, scif_dbg, NULL, &scif_rma_fops);
123 debugfs_create_u8("en_msg_log", 0666, scif_dbg, &scif_info.en_msg_log);
124 debugfs_create_u8("p2p_enable", 0666, scif_dbg, &scif_info.p2p_enable);
127 void scif_exit_debugfs(void)
129 debugfs_remove_recursive(scif_dbg);