1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// SPDX-License-Identifier: GPL-2.0+
/* Microchip VCAP API debug file system support
*
* Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries.
*
*/
#include <linux/types.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/netdevice.h>
#include "vcap_api_debugfs.h"
struct vcap_admin_debugfs_info {
struct vcap_control *vctrl;
struct vcap_admin *admin;
};
struct vcap_port_debugfs_info {
struct vcap_control *vctrl;
struct net_device *ndev;
};
/* Show the port configuration and status */
static int vcap_port_debugfs_show(struct seq_file *m, void *unused)
{
struct vcap_port_debugfs_info *info = m->private;
struct vcap_admin *admin;
struct vcap_output_print out = {
.prf = (void *)seq_printf,
.dst = m,
};
list_for_each_entry(admin, &info->vctrl->list, list) {
if (admin->vinst)
continue;
info->vctrl->ops->port_info(info->ndev, admin, &out);
}
return 0;
}
DEFINE_SHOW_ATTRIBUTE(vcap_port_debugfs);
void vcap_port_debugfs(struct device *dev, struct dentry *parent,
struct vcap_control *vctrl,
struct net_device *ndev)
{
struct vcap_port_debugfs_info *info;
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
if (!info)
return;
info->vctrl = vctrl;
info->ndev = ndev;
debugfs_create_file(netdev_name(ndev), 0444, parent, info,
&vcap_port_debugfs_fops);
}
EXPORT_SYMBOL_GPL(vcap_port_debugfs);
/* Show the raw VCAP instance data (rules with address info) */
static int vcap_raw_debugfs_show(struct seq_file *m, void *unused)
{
/* The output will be added later */
return 0;
}
DEFINE_SHOW_ATTRIBUTE(vcap_raw_debugfs);
struct dentry *vcap_debugfs(struct device *dev, struct dentry *parent,
struct vcap_control *vctrl)
{
struct vcap_admin_debugfs_info *info;
struct vcap_admin *admin;
struct dentry *dir;
char name[50];
dir = debugfs_create_dir("vcaps", parent);
if (PTR_ERR_OR_ZERO(dir))
return NULL;
list_for_each_entry(admin, &vctrl->list, list) {
sprintf(name, "raw_%s_%d", vctrl->vcaps[admin->vtype].name,
admin->vinst);
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
if (!info)
return NULL;
info->vctrl = vctrl;
info->admin = admin;
debugfs_create_file(name, 0444, dir, info,
&vcap_raw_debugfs_fops);
}
return dir;
}
EXPORT_SYMBOL_GPL(vcap_debugfs);
|