]> Git Repo - linux.git/blob - drivers/misc/mic/vop/vop_debugfs.c
ARM: dts: imx7s: Enable SNVS power key according to board design
[linux.git] / drivers / misc / mic / vop / vop_debugfs.c
1 /*
2  * Intel MIC Platform Software Stack (MPSS)
3  *
4  * Copyright(c) 2016 Intel Corporation.
5  *
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.
9  *
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.
14  *
15  * The full GNU General Public License is included in this distribution in
16  * the file called "COPYING".
17  *
18  * Intel Virtio Over PCIe (VOP) driver.
19  *
20  */
21 #include <linux/debugfs.h>
22 #include <linux/seq_file.h>
23
24 #include "vop_main.h"
25
26 static int vop_dp_show(struct seq_file *s, void *pos)
27 {
28         struct mic_device_desc *d;
29         struct mic_device_ctrl *dc;
30         struct mic_vqconfig *vqconfig;
31         __u32 *features;
32         __u8 *config;
33         struct vop_info *vi = s->private;
34         struct vop_device *vpdev = vi->vpdev;
35         struct mic_bootparam *bootparam = vpdev->hw_ops->get_dp(vpdev);
36         int j, k;
37
38         seq_printf(s, "Bootparam: magic 0x%x\n",
39                    bootparam->magic);
40         seq_printf(s, "Bootparam: h2c_config_db %d\n",
41                    bootparam->h2c_config_db);
42         seq_printf(s, "Bootparam: node_id %d\n",
43                    bootparam->node_id);
44         seq_printf(s, "Bootparam: c2h_scif_db %d\n",
45                    bootparam->c2h_scif_db);
46         seq_printf(s, "Bootparam: h2c_scif_db %d\n",
47                    bootparam->h2c_scif_db);
48         seq_printf(s, "Bootparam: scif_host_dma_addr 0x%llx\n",
49                    bootparam->scif_host_dma_addr);
50         seq_printf(s, "Bootparam: scif_card_dma_addr 0x%llx\n",
51                    bootparam->scif_card_dma_addr);
52
53         for (j = sizeof(*bootparam);
54                 j < MIC_DP_SIZE; j += mic_total_desc_size(d)) {
55                 d = (void *)bootparam + j;
56                 dc = (void *)d + mic_aligned_desc_size(d);
57
58                 /* end of list */
59                 if (d->type == 0)
60                         break;
61
62                 if (d->type == -1)
63                         continue;
64
65                 seq_printf(s, "Type %d ", d->type);
66                 seq_printf(s, "Num VQ %d ", d->num_vq);
67                 seq_printf(s, "Feature Len %d\n", d->feature_len);
68                 seq_printf(s, "Config Len %d ", d->config_len);
69                 seq_printf(s, "Shutdown Status %d\n", d->status);
70
71                 for (k = 0; k < d->num_vq; k++) {
72                         vqconfig = mic_vq_config(d) + k;
73                         seq_printf(s, "vqconfig[%d]: ", k);
74                         seq_printf(s, "address 0x%llx ",
75                                    vqconfig->address);
76                         seq_printf(s, "num %d ", vqconfig->num);
77                         seq_printf(s, "used address 0x%llx\n",
78                                    vqconfig->used_address);
79                 }
80
81                 features = (__u32 *)mic_vq_features(d);
82                 seq_printf(s, "Features: Host 0x%x ", features[0]);
83                 seq_printf(s, "Guest 0x%x\n", features[1]);
84
85                 config = mic_vq_configspace(d);
86                 for (k = 0; k < d->config_len; k++)
87                         seq_printf(s, "config[%d]=%d\n", k, config[k]);
88
89                 seq_puts(s, "Device control:\n");
90                 seq_printf(s, "Config Change %d ", dc->config_change);
91                 seq_printf(s, "Vdev reset %d\n", dc->vdev_reset);
92                 seq_printf(s, "Guest Ack %d ", dc->guest_ack);
93                 seq_printf(s, "Host ack %d\n", dc->host_ack);
94                 seq_printf(s, "Used address updated %d ",
95                            dc->used_address_updated);
96                 seq_printf(s, "Vdev 0x%llx\n", dc->vdev);
97                 seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db);
98                 seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db);
99         }
100         schedule_work(&vi->hotplug_work);
101         return 0;
102 }
103
104 DEFINE_SHOW_ATTRIBUTE(vop_dp);
105
106 static int vop_vdev_info_show(struct seq_file *s, void *unused)
107 {
108         struct vop_info *vi = s->private;
109         struct list_head *pos, *tmp;
110         struct vop_vdev *vdev;
111         int i, j;
112
113         mutex_lock(&vi->vop_mutex);
114         list_for_each_safe(pos, tmp, &vi->vdev_list) {
115                 vdev = list_entry(pos, struct vop_vdev, list);
116                 seq_printf(s, "VDEV type %d state %s in %ld out %ld in_dma %ld out_dma %ld\n",
117                            vdev->virtio_id,
118                            vop_vdevup(vdev) ? "UP" : "DOWN",
119                            vdev->in_bytes,
120                            vdev->out_bytes,
121                            vdev->in_bytes_dma,
122                            vdev->out_bytes_dma);
123                 for (i = 0; i < MIC_MAX_VRINGS; i++) {
124                         struct vring_desc *desc;
125                         struct vring_avail *avail;
126                         struct vring_used *used;
127                         struct vop_vringh *vvr = &vdev->vvr[i];
128                         struct vringh *vrh = &vvr->vrh;
129                         int num = vrh->vring.num;
130
131                         if (!num)
132                                 continue;
133                         desc = vrh->vring.desc;
134                         seq_printf(s, "vring i %d avail_idx %d",
135                                    i, vvr->vring.info->avail_idx & (num - 1));
136                         seq_printf(s, " vring i %d avail_idx %d\n",
137                                    i, vvr->vring.info->avail_idx);
138                         seq_printf(s, "vrh i %d weak_barriers %d",
139                                    i, vrh->weak_barriers);
140                         seq_printf(s, " last_avail_idx %d last_used_idx %d",
141                                    vrh->last_avail_idx, vrh->last_used_idx);
142                         seq_printf(s, " completed %d\n", vrh->completed);
143                         for (j = 0; j < num; j++) {
144                                 seq_printf(s, "desc[%d] addr 0x%llx len %d",
145                                            j, desc->addr, desc->len);
146                                 seq_printf(s, " flags 0x%x next %d\n",
147                                            desc->flags, desc->next);
148                                 desc++;
149                         }
150                         avail = vrh->vring.avail;
151                         seq_printf(s, "avail flags 0x%x idx %d\n",
152                                    vringh16_to_cpu(vrh, avail->flags),
153                                    vringh16_to_cpu(vrh,
154                                                    avail->idx) & (num - 1));
155                         seq_printf(s, "avail flags 0x%x idx %d\n",
156                                    vringh16_to_cpu(vrh, avail->flags),
157                                    vringh16_to_cpu(vrh, avail->idx));
158                         for (j = 0; j < num; j++)
159                                 seq_printf(s, "avail ring[%d] %d\n",
160                                            j, avail->ring[j]);
161                         used = vrh->vring.used;
162                         seq_printf(s, "used flags 0x%x idx %d\n",
163                                    vringh16_to_cpu(vrh, used->flags),
164                                    vringh16_to_cpu(vrh, used->idx) & (num - 1));
165                         seq_printf(s, "used flags 0x%x idx %d\n",
166                                    vringh16_to_cpu(vrh, used->flags),
167                                    vringh16_to_cpu(vrh, used->idx));
168                         for (j = 0; j < num; j++)
169                                 seq_printf(s, "used ring[%d] id %d len %d\n",
170                                            j, vringh32_to_cpu(vrh,
171                                                               used->ring[j].id),
172                                            vringh32_to_cpu(vrh,
173                                                            used->ring[j].len));
174                 }
175         }
176         mutex_unlock(&vi->vop_mutex);
177
178         return 0;
179 }
180
181 DEFINE_SHOW_ATTRIBUTE(vop_vdev_info);
182
183 void vop_init_debugfs(struct vop_info *vi)
184 {
185         char name[16];
186
187         snprintf(name, sizeof(name), "%s%d", KBUILD_MODNAME, vi->vpdev->dnode);
188         vi->dbg = debugfs_create_dir(name, NULL);
189         if (!vi->dbg) {
190                 pr_err("can't create debugfs dir vop\n");
191                 return;
192         }
193         debugfs_create_file("dp", 0444, vi->dbg, vi, &vop_dp_fops);
194         debugfs_create_file("vdev_info", 0444, vi->dbg, vi, &vop_vdev_info_fops);
195 }
196
197 void vop_exit_debugfs(struct vop_info *vi)
198 {
199         debugfs_remove_recursive(vi->dbg);
200 }
This page took 0.044749 seconds and 4 git commands to generate.