forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/scsi/qedf/qedf_debugfs.c
....@@ -1,10 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * QLogic FCoE Offload Driver
34 * Copyright (c) 2016-2018 QLogic Corporation
4
- *
5
- * This software is available under the terms of the GNU General Public License
6
- * (GPL) Version 2, available from the file COPYING in the main directory of
7
- * this source tree.
85 */
96 #ifdef CONFIG_DEBUG_FS
107
....@@ -17,62 +14,49 @@
1714
1815 static struct dentry *qedf_dbg_root;
1916
20
-/**
17
+/*
2118 * qedf_dbg_host_init - setup the debugfs file for the pf
22
- * @pf: the pf that is starting up
23
- **/
19
+ */
2420 void
2521 qedf_dbg_host_init(struct qedf_dbg_ctx *qedf,
2622 const struct qedf_debugfs_ops *dops,
2723 const struct file_operations *fops)
2824 {
2925 char host_dirname[32];
30
- struct dentry *file_dentry = NULL;
3126
3227 QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Creating debugfs host node\n");
3328 /* create pf dir */
3429 sprintf(host_dirname, "host%u", qedf->host_no);
3530 qedf->bdf_dentry = debugfs_create_dir(host_dirname, qedf_dbg_root);
36
- if (!qedf->bdf_dentry)
37
- return;
3831
3932 /* create debugfs files */
4033 while (dops) {
4134 if (!(dops->name))
4235 break;
4336
44
- file_dentry = debugfs_create_file(dops->name, 0600,
45
- qedf->bdf_dentry, qedf,
46
- fops);
47
- if (!file_dentry) {
48
- QEDF_INFO(qedf, QEDF_LOG_DEBUGFS,
49
- "Debugfs entry %s creation failed\n",
50
- dops->name);
51
- debugfs_remove_recursive(qedf->bdf_dentry);
52
- return;
53
- }
37
+ debugfs_create_file(dops->name, 0600, qedf->bdf_dentry, qedf,
38
+ fops);
5439 dops++;
5540 fops++;
5641 }
5742 }
5843
59
-/**
44
+/*
6045 * qedf_dbg_host_exit - clear out the pf's debugfs entries
61
- * @pf: the pf that is stopping
62
- **/
46
+ */
6347 void
64
-qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf)
48
+qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf_dbg)
6549 {
66
- QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Destroying debugfs host "
50
+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Destroying debugfs host "
6751 "entry\n");
6852 /* remove debugfs entries of this PF */
69
- debugfs_remove_recursive(qedf->bdf_dentry);
70
- qedf->bdf_dentry = NULL;
53
+ debugfs_remove_recursive(qedf_dbg->bdf_dentry);
54
+ qedf_dbg->bdf_dentry = NULL;
7155 }
7256
73
-/**
57
+/*
7458 * qedf_dbg_init - start up debugfs for the driver
75
- **/
59
+ */
7660 void
7761 qedf_dbg_init(char *drv_name)
7862 {
....@@ -80,14 +64,11 @@
8064
8165 /* create qed dir in root of debugfs. NULL means debugfs root */
8266 qedf_dbg_root = debugfs_create_dir(drv_name, NULL);
83
- if (!qedf_dbg_root)
84
- QEDF_INFO(NULL, QEDF_LOG_DEBUGFS, "Init of debugfs "
85
- "failed\n");
8667 }
8768
88
-/**
69
+/*
8970 * qedf_dbg_exit - clean out the driver's debugfs entries
90
- **/
71
+ */
9172 void
9273 qedf_dbg_exit(void)
9374 {
....@@ -157,10 +138,10 @@
157138 loff_t *ppos)
158139 {
159140 int cnt;
160
- struct qedf_dbg_ctx *qedf =
141
+ struct qedf_dbg_ctx *qedf_dbg =
161142 (struct qedf_dbg_ctx *)filp->private_data;
162143
163
- QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "entered\n");
144
+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "debug mask=0x%x\n", qedf_debug);
164145 cnt = sprintf(buffer, "debug mask = 0x%x\n", qedf_debug);
165146
166147 cnt = min_t(int, count, cnt - *ppos);
....@@ -175,7 +156,7 @@
175156 uint32_t val;
176157 void *kern_buf;
177158 int rval;
178
- struct qedf_dbg_ctx *qedf =
159
+ struct qedf_dbg_ctx *qedf_dbg =
179160 (struct qedf_dbg_ctx *)filp->private_data;
180161
181162 if (!count || *ppos)
....@@ -195,7 +176,7 @@
195176 else
196177 qedf_debug = val;
197178
198
- QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Setting debug=0x%x.\n", val);
179
+ QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Setting debug=0x%x.\n", val);
199180 return count;
200181 }
201182
....@@ -307,6 +288,33 @@
307288 return single_open(file, qedf_io_trace_show, qedf);
308289 }
309290
291
+/* Based on fip_state enum from libfcoe.h */
292
+static char *fip_state_names[] = {
293
+ "FIP_ST_DISABLED",
294
+ "FIP_ST_LINK_WAIT",
295
+ "FIP_ST_AUTO",
296
+ "FIP_ST_NON_FIP",
297
+ "FIP_ST_ENABLED",
298
+ "FIP_ST_VNMP_START",
299
+ "FIP_ST_VNMP_PROBE1",
300
+ "FIP_ST_VNMP_PROBE2",
301
+ "FIP_ST_VNMP_CLAIM",
302
+ "FIP_ST_VNMP_UP",
303
+};
304
+
305
+/* Based on fc_rport_state enum from libfc.h */
306
+static char *fc_rport_state_names[] = {
307
+ "RPORT_ST_INIT",
308
+ "RPORT_ST_FLOGI",
309
+ "RPORT_ST_PLOGI_WAIT",
310
+ "RPORT_ST_PLOGI",
311
+ "RPORT_ST_PRLI",
312
+ "RPORT_ST_RTV",
313
+ "RPORT_ST_READY",
314
+ "RPORT_ST_ADISC",
315
+ "RPORT_ST_DELETE",
316
+};
317
+
310318 static int
311319 qedf_driver_stats_show(struct seq_file *s, void *unused)
312320 {
....@@ -314,10 +322,28 @@
314322 struct qedf_rport *fcport;
315323 struct fc_rport_priv *rdata;
316324
325
+ seq_printf(s, "Host WWNN/WWPN: %016llx/%016llx\n",
326
+ qedf->wwnn, qedf->wwpn);
327
+ seq_printf(s, "Host NPortID: %06x\n", qedf->lport->port_id);
328
+ seq_printf(s, "Link State: %s\n", atomic_read(&qedf->link_state) ?
329
+ "Up" : "Down");
330
+ seq_printf(s, "Logical Link State: %s\n", qedf->lport->link_up ?
331
+ "Up" : "Down");
332
+ seq_printf(s, "FIP state: %s\n", fip_state_names[qedf->ctlr.state]);
333
+ seq_printf(s, "FIP VLAN ID: %d\n", qedf->vlan_id & 0xfff);
334
+ seq_printf(s, "FIP 802.1Q Priority: %d\n", qedf->prio);
335
+ if (qedf->ctlr.sel_fcf) {
336
+ seq_printf(s, "FCF WWPN: %016llx\n",
337
+ qedf->ctlr.sel_fcf->switch_name);
338
+ seq_printf(s, "FCF MAC: %pM\n", qedf->ctlr.sel_fcf->fcf_mac);
339
+ } else {
340
+ seq_puts(s, "FCF not selected\n");
341
+ }
342
+
343
+ seq_puts(s, "\nSGE stats:\n\n");
317344 seq_printf(s, "cmg_mgr free io_reqs: %d\n",
318345 atomic_read(&qedf->cmd_mgr->free_list_cnt));
319346 seq_printf(s, "slow SGEs: %d\n", qedf->slow_sge_ios);
320
- seq_printf(s, "single SGEs: %d\n", qedf->single_sge_ios);
321347 seq_printf(s, "fast SGEs: %d\n\n", qedf->fast_sge_ios);
322348
323349 seq_puts(s, "Offloaded ports:\n\n");
....@@ -327,9 +353,12 @@
327353 rdata = fcport->rdata;
328354 if (rdata == NULL)
329355 continue;
330
- seq_printf(s, "%06x: free_sqes: %d, num_active_ios: %d\n",
331
- rdata->ids.port_id, atomic_read(&fcport->free_sqes),
332
- atomic_read(&fcport->num_active_ios));
356
+ seq_printf(s, "%016llx/%016llx/%06x: state=%s, free_sqes=%d, num_active_ios=%d\n",
357
+ rdata->rport->node_name, rdata->rport->port_name,
358
+ rdata->ids.port_id,
359
+ fc_rport_state_names[rdata->rp_state],
360
+ atomic_read(&fcport->free_sqes),
361
+ atomic_read(&fcport->num_active_ios));
333362 }
334363 rcu_read_unlock();
335364
....@@ -375,7 +404,6 @@
375404
376405 /* Clear stat counters exposed by 'stats' node */
377406 qedf->slow_sge_ios = 0;
378
- qedf->single_sge_ios = 0;
379407 qedf->fast_sge_ios = 0;
380408
381409 return count;