| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * QLogic FCoE Offload Driver |
|---|
| 3 | 4 | * 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. |
|---|
| 8 | 5 | */ |
|---|
| 9 | 6 | #ifdef CONFIG_DEBUG_FS |
|---|
| 10 | 7 | |
|---|
| .. | .. |
|---|
| 17 | 14 | |
|---|
| 18 | 15 | static struct dentry *qedf_dbg_root; |
|---|
| 19 | 16 | |
|---|
| 20 | | -/** |
|---|
| 17 | +/* |
|---|
| 21 | 18 | * qedf_dbg_host_init - setup the debugfs file for the pf |
|---|
| 22 | | - * @pf: the pf that is starting up |
|---|
| 23 | | - **/ |
|---|
| 19 | + */ |
|---|
| 24 | 20 | void |
|---|
| 25 | 21 | qedf_dbg_host_init(struct qedf_dbg_ctx *qedf, |
|---|
| 26 | 22 | const struct qedf_debugfs_ops *dops, |
|---|
| 27 | 23 | const struct file_operations *fops) |
|---|
| 28 | 24 | { |
|---|
| 29 | 25 | char host_dirname[32]; |
|---|
| 30 | | - struct dentry *file_dentry = NULL; |
|---|
| 31 | 26 | |
|---|
| 32 | 27 | QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Creating debugfs host node\n"); |
|---|
| 33 | 28 | /* create pf dir */ |
|---|
| 34 | 29 | sprintf(host_dirname, "host%u", qedf->host_no); |
|---|
| 35 | 30 | qedf->bdf_dentry = debugfs_create_dir(host_dirname, qedf_dbg_root); |
|---|
| 36 | | - if (!qedf->bdf_dentry) |
|---|
| 37 | | - return; |
|---|
| 38 | 31 | |
|---|
| 39 | 32 | /* create debugfs files */ |
|---|
| 40 | 33 | while (dops) { |
|---|
| 41 | 34 | if (!(dops->name)) |
|---|
| 42 | 35 | break; |
|---|
| 43 | 36 | |
|---|
| 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); |
|---|
| 54 | 39 | dops++; |
|---|
| 55 | 40 | fops++; |
|---|
| 56 | 41 | } |
|---|
| 57 | 42 | } |
|---|
| 58 | 43 | |
|---|
| 59 | | -/** |
|---|
| 44 | +/* |
|---|
| 60 | 45 | * qedf_dbg_host_exit - clear out the pf's debugfs entries |
|---|
| 61 | | - * @pf: the pf that is stopping |
|---|
| 62 | | - **/ |
|---|
| 46 | + */ |
|---|
| 63 | 47 | void |
|---|
| 64 | | -qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf) |
|---|
| 48 | +qedf_dbg_host_exit(struct qedf_dbg_ctx *qedf_dbg) |
|---|
| 65 | 49 | { |
|---|
| 66 | | - QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "Destroying debugfs host " |
|---|
| 50 | + QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "Destroying debugfs host " |
|---|
| 67 | 51 | "entry\n"); |
|---|
| 68 | 52 | /* 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; |
|---|
| 71 | 55 | } |
|---|
| 72 | 56 | |
|---|
| 73 | | -/** |
|---|
| 57 | +/* |
|---|
| 74 | 58 | * qedf_dbg_init - start up debugfs for the driver |
|---|
| 75 | | - **/ |
|---|
| 59 | + */ |
|---|
| 76 | 60 | void |
|---|
| 77 | 61 | qedf_dbg_init(char *drv_name) |
|---|
| 78 | 62 | { |
|---|
| .. | .. |
|---|
| 80 | 64 | |
|---|
| 81 | 65 | /* create qed dir in root of debugfs. NULL means debugfs root */ |
|---|
| 82 | 66 | 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"); |
|---|
| 86 | 67 | } |
|---|
| 87 | 68 | |
|---|
| 88 | | -/** |
|---|
| 69 | +/* |
|---|
| 89 | 70 | * qedf_dbg_exit - clean out the driver's debugfs entries |
|---|
| 90 | | - **/ |
|---|
| 71 | + */ |
|---|
| 91 | 72 | void |
|---|
| 92 | 73 | qedf_dbg_exit(void) |
|---|
| 93 | 74 | { |
|---|
| .. | .. |
|---|
| 157 | 138 | loff_t *ppos) |
|---|
| 158 | 139 | { |
|---|
| 159 | 140 | int cnt; |
|---|
| 160 | | - struct qedf_dbg_ctx *qedf = |
|---|
| 141 | + struct qedf_dbg_ctx *qedf_dbg = |
|---|
| 161 | 142 | (struct qedf_dbg_ctx *)filp->private_data; |
|---|
| 162 | 143 | |
|---|
| 163 | | - QEDF_INFO(qedf, QEDF_LOG_DEBUGFS, "entered\n"); |
|---|
| 144 | + QEDF_INFO(qedf_dbg, QEDF_LOG_DEBUGFS, "debug mask=0x%x\n", qedf_debug); |
|---|
| 164 | 145 | cnt = sprintf(buffer, "debug mask = 0x%x\n", qedf_debug); |
|---|
| 165 | 146 | |
|---|
| 166 | 147 | cnt = min_t(int, count, cnt - *ppos); |
|---|
| .. | .. |
|---|
| 175 | 156 | uint32_t val; |
|---|
| 176 | 157 | void *kern_buf; |
|---|
| 177 | 158 | int rval; |
|---|
| 178 | | - struct qedf_dbg_ctx *qedf = |
|---|
| 159 | + struct qedf_dbg_ctx *qedf_dbg = |
|---|
| 179 | 160 | (struct qedf_dbg_ctx *)filp->private_data; |
|---|
| 180 | 161 | |
|---|
| 181 | 162 | if (!count || *ppos) |
|---|
| .. | .. |
|---|
| 195 | 176 | else |
|---|
| 196 | 177 | qedf_debug = val; |
|---|
| 197 | 178 | |
|---|
| 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); |
|---|
| 199 | 180 | return count; |
|---|
| 200 | 181 | } |
|---|
| 201 | 182 | |
|---|
| .. | .. |
|---|
| 307 | 288 | return single_open(file, qedf_io_trace_show, qedf); |
|---|
| 308 | 289 | } |
|---|
| 309 | 290 | |
|---|
| 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 | + |
|---|
| 310 | 318 | static int |
|---|
| 311 | 319 | qedf_driver_stats_show(struct seq_file *s, void *unused) |
|---|
| 312 | 320 | { |
|---|
| .. | .. |
|---|
| 314 | 322 | struct qedf_rport *fcport; |
|---|
| 315 | 323 | struct fc_rport_priv *rdata; |
|---|
| 316 | 324 | |
|---|
| 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"); |
|---|
| 317 | 344 | seq_printf(s, "cmg_mgr free io_reqs: %d\n", |
|---|
| 318 | 345 | atomic_read(&qedf->cmd_mgr->free_list_cnt)); |
|---|
| 319 | 346 | seq_printf(s, "slow SGEs: %d\n", qedf->slow_sge_ios); |
|---|
| 320 | | - seq_printf(s, "single SGEs: %d\n", qedf->single_sge_ios); |
|---|
| 321 | 347 | seq_printf(s, "fast SGEs: %d\n\n", qedf->fast_sge_ios); |
|---|
| 322 | 348 | |
|---|
| 323 | 349 | seq_puts(s, "Offloaded ports:\n\n"); |
|---|
| .. | .. |
|---|
| 327 | 353 | rdata = fcport->rdata; |
|---|
| 328 | 354 | if (rdata == NULL) |
|---|
| 329 | 355 | 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)); |
|---|
| 333 | 362 | } |
|---|
| 334 | 363 | rcu_read_unlock(); |
|---|
| 335 | 364 | |
|---|
| .. | .. |
|---|
| 375 | 404 | |
|---|
| 376 | 405 | /* Clear stat counters exposed by 'stats' node */ |
|---|
| 377 | 406 | qedf->slow_sge_ios = 0; |
|---|
| 378 | | - qedf->single_sge_ios = 0; |
|---|
| 379 | 407 | qedf->fast_sge_ios = 0; |
|---|
| 380 | 408 | |
|---|
| 381 | 409 | return count; |
|---|