root/drivers/misc/mic/scif/scif_debugfs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. scif_dev_show
  2. scif_display_window
  3. scif_display_all_windows
  4. scif_rma_show
  5. scif_init_debugfs
  6. scif_exit_debugfs

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * Intel MIC Platform Software Stack (MPSS)
   4  *
   5  * Copyright(c) 2014 Intel Corporation.
   6  *
   7  * Intel SCIF driver.
   8  */
   9 #include <linux/debugfs.h>
  10 #include <linux/seq_file.h>
  11 
  12 #include "../common/mic_dev.h"
  13 #include "scif_main.h"
  14 
  15 /* Debugfs parent dir */
  16 static struct dentry *scif_dbg;
  17 
  18 static int scif_dev_show(struct seq_file *s, void *unused)
  19 {
  20         int node;
  21 
  22         seq_printf(s, "Total Nodes %d Self Node Id %d Maxid %d\n",
  23                    scif_info.total, scif_info.nodeid,
  24                    scif_info.maxid);
  25 
  26         if (!scif_dev)
  27                 return 0;
  28 
  29         seq_printf(s, "%-16s\t%-16s\n", "node_id", "state");
  30 
  31         for (node = 0; node <= scif_info.maxid; node++)
  32                 seq_printf(s, "%-16d\t%-16s\n", scif_dev[node].node,
  33                            _scifdev_alive(&scif_dev[node]) ?
  34                            "Running" : "Offline");
  35         return 0;
  36 }
  37 
  38 DEFINE_SHOW_ATTRIBUTE(scif_dev);
  39 
  40 static void scif_display_window(struct scif_window *window, struct seq_file *s)
  41 {
  42         int j;
  43         struct scatterlist *sg;
  44         scif_pinned_pages_t pin = window->pinned_pages;
  45 
  46         seq_printf(s, "window %p type %d temp %d offset 0x%llx ",
  47                    window, window->type, window->temp, window->offset);
  48         seq_printf(s, "nr_pages 0x%llx nr_contig_chunks 0x%x prot %d ",
  49                    window->nr_pages, window->nr_contig_chunks, window->prot);
  50         seq_printf(s, "ref_count %d magic 0x%llx peer_window 0x%llx ",
  51                    window->ref_count, window->magic, window->peer_window);
  52         seq_printf(s, "unreg_state 0x%x va_for_temp 0x%lx\n",
  53                    window->unreg_state, window->va_for_temp);
  54 
  55         for (j = 0; j < window->nr_contig_chunks; j++)
  56                 seq_printf(s, "page[%d] dma_addr 0x%llx num_pages 0x%llx\n", j,
  57                            window->dma_addr[j], window->num_pages[j]);
  58 
  59         if (window->type == SCIF_WINDOW_SELF && pin)
  60                 for (j = 0; j < window->nr_pages; j++)
  61                         seq_printf(s, "page[%d] = pinned_pages %p address %p\n",
  62                                    j, pin->pages[j],
  63                                    page_address(pin->pages[j]));
  64 
  65         if (window->st)
  66                 for_each_sg(window->st->sgl, sg, window->st->nents, j)
  67                         seq_printf(s, "sg[%d] dma addr 0x%llx length 0x%x\n",
  68                                    j, sg_dma_address(sg), sg_dma_len(sg));
  69 }
  70 
  71 static void scif_display_all_windows(struct list_head *head, struct seq_file *s)
  72 {
  73         struct list_head *item;
  74         struct scif_window *window;
  75 
  76         list_for_each(item, head) {
  77                 window = list_entry(item, struct scif_window, list);
  78                 scif_display_window(window, s);
  79         }
  80 }
  81 
  82 static int scif_rma_show(struct seq_file *s, void *unused)
  83 {
  84         struct scif_endpt *ep;
  85         struct list_head *pos;
  86 
  87         mutex_lock(&scif_info.connlock);
  88         list_for_each(pos, &scif_info.connected) {
  89                 ep = list_entry(pos, struct scif_endpt, list);
  90                 seq_printf(s, "ep %p self windows\n", ep);
  91                 mutex_lock(&ep->rma_info.rma_lock);
  92                 scif_display_all_windows(&ep->rma_info.reg_list, s);
  93                 seq_printf(s, "ep %p remote windows\n", ep);
  94                 scif_display_all_windows(&ep->rma_info.remote_reg_list, s);
  95                 mutex_unlock(&ep->rma_info.rma_lock);
  96         }
  97         mutex_unlock(&scif_info.connlock);
  98         return 0;
  99 }
 100 
 101 DEFINE_SHOW_ATTRIBUTE(scif_rma);
 102 
 103 void __init scif_init_debugfs(void)
 104 {
 105         scif_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
 106 
 107         debugfs_create_file("scif_dev", 0444, scif_dbg, NULL, &scif_dev_fops);
 108         debugfs_create_file("scif_rma", 0444, scif_dbg, NULL, &scif_rma_fops);
 109         debugfs_create_u8("en_msg_log", 0666, scif_dbg, &scif_info.en_msg_log);
 110         debugfs_create_u8("p2p_enable", 0666, scif_dbg, &scif_info.p2p_enable);
 111 }
 112 
 113 void scif_exit_debugfs(void)
 114 {
 115         debugfs_remove_recursive(scif_dbg);
 116 }

/* [<][>][^][v][top][bottom][index][help] */