forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/netronome/nfp/nfp_net_debugfs.c
....@@ -1,35 +1,5 @@
1
-/*
2
- * Copyright (C) 2015-2017 Netronome Systems, Inc.
3
- *
4
- * This software is dual licensed under the GNU General License Version 2,
5
- * June 1991 as shown in the file COPYING in the top-level directory of this
6
- * source tree or the BSD 2-Clause License provided below. You have the
7
- * option to license this software under the complete terms of either license.
8
- *
9
- * The BSD 2-Clause License:
10
- *
11
- * Redistribution and use in source and binary forms, with or
12
- * without modification, are permitted provided that the following
13
- * conditions are met:
14
- *
15
- * 1. Redistributions of source code must retain the above
16
- * copyright notice, this list of conditions and the following
17
- * disclaimer.
18
- *
19
- * 2. Redistributions in binary form must reproduce the above
20
- * copyright notice, this list of conditions and the following
21
- * disclaimer in the documentation and/or other materials
22
- * provided with the distribution.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
1
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2
+/* Copyright (C) 2015-2018 Netronome Systems, Inc. */
333 #include <linux/debugfs.h>
344 #include <linux/module.h>
355 #include <linux/rtnetlink.h>
....@@ -38,7 +8,7 @@
388
399 static struct dentry *nfp_dir;
4010
41
-static int nfp_net_debugfs_rx_q_read(struct seq_file *file, void *data)
11
+static int nfp_rx_q_show(struct seq_file *file, void *data)
4212 {
4313 struct nfp_net_r_vector *r_vec = file->private;
4414 struct nfp_net_rx_ring *rx_ring;
....@@ -95,31 +65,12 @@
9565 rtnl_unlock();
9666 return 0;
9767 }
68
+DEFINE_SHOW_ATTRIBUTE(nfp_rx_q);
9869
99
-static int nfp_net_debugfs_rx_q_open(struct inode *inode, struct file *f)
100
-{
101
- return single_open(f, nfp_net_debugfs_rx_q_read, inode->i_private);
102
-}
70
+static int nfp_tx_q_show(struct seq_file *file, void *data);
71
+DEFINE_SHOW_ATTRIBUTE(nfp_tx_q);
10372
104
-static const struct file_operations nfp_rx_q_fops = {
105
- .owner = THIS_MODULE,
106
- .open = nfp_net_debugfs_rx_q_open,
107
- .release = single_release,
108
- .read = seq_read,
109
- .llseek = seq_lseek
110
-};
111
-
112
-static int nfp_net_debugfs_tx_q_open(struct inode *inode, struct file *f);
113
-
114
-static const struct file_operations nfp_tx_q_fops = {
115
- .owner = THIS_MODULE,
116
- .open = nfp_net_debugfs_tx_q_open,
117
- .release = single_release,
118
- .read = seq_read,
119
- .llseek = seq_lseek
120
-};
121
-
122
-static int nfp_net_debugfs_tx_q_read(struct seq_file *file, void *data)
73
+static int nfp_tx_q_show(struct seq_file *file, void *data)
12374 {
12475 struct nfp_net_r_vector *r_vec = file->private;
12576 struct nfp_net_tx_ring *tx_ring;
....@@ -188,18 +139,11 @@
188139 return 0;
189140 }
190141
191
-static int nfp_net_debugfs_tx_q_open(struct inode *inode, struct file *f)
142
+static int nfp_xdp_q_show(struct seq_file *file, void *data)
192143 {
193
- return single_open(f, nfp_net_debugfs_tx_q_read, inode->i_private);
144
+ return nfp_tx_q_show(file, data);
194145 }
195
-
196
-static const struct file_operations nfp_xdp_q_fops = {
197
- .owner = THIS_MODULE,
198
- .open = nfp_net_debugfs_tx_q_open,
199
- .release = single_release,
200
- .read = seq_read,
201
- .llseek = seq_lseek
202
-};
146
+DEFINE_SHOW_ATTRIBUTE(nfp_xdp_q);
203147
204148 void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir)
205149 {
....@@ -215,19 +159,13 @@
215159 else
216160 strcpy(name, "ctrl-vnic");
217161 nn->debugfs_dir = debugfs_create_dir(name, ddir);
218
- if (IS_ERR_OR_NULL(nn->debugfs_dir))
219
- return;
220162
221163 /* Create queue debugging sub-tree */
222164 queues = debugfs_create_dir("queue", nn->debugfs_dir);
223
- if (IS_ERR_OR_NULL(queues))
224
- return;
225165
226166 rx = debugfs_create_dir("rx", queues);
227167 tx = debugfs_create_dir("tx", queues);
228168 xdp = debugfs_create_dir("xdp", queues);
229
- if (IS_ERR_OR_NULL(rx) || IS_ERR_OR_NULL(tx) || IS_ERR_OR_NULL(xdp))
230
- return;
231169
232170 for (i = 0; i < min(nn->max_rx_rings, nn->max_r_vecs); i++) {
233171 sprintf(name, "%d", i);
....@@ -246,16 +184,7 @@
246184
247185 struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev)
248186 {
249
- struct dentry *dev_dir;
250
-
251
- if (IS_ERR_OR_NULL(nfp_dir))
252
- return NULL;
253
-
254
- dev_dir = debugfs_create_dir(pci_name(pdev), nfp_dir);
255
- if (IS_ERR_OR_NULL(dev_dir))
256
- return NULL;
257
-
258
- return dev_dir;
187
+ return debugfs_create_dir(pci_name(pdev), nfp_dir);
259188 }
260189
261190 void nfp_net_debugfs_dir_clean(struct dentry **dir)