| .. | .. |
|---|
| 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. */ |
|---|
| 33 | 3 | #include <linux/debugfs.h> |
|---|
| 34 | 4 | #include <linux/module.h> |
|---|
| 35 | 5 | #include <linux/rtnetlink.h> |
|---|
| .. | .. |
|---|
| 38 | 8 | |
|---|
| 39 | 9 | static struct dentry *nfp_dir; |
|---|
| 40 | 10 | |
|---|
| 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) |
|---|
| 42 | 12 | { |
|---|
| 43 | 13 | struct nfp_net_r_vector *r_vec = file->private; |
|---|
| 44 | 14 | struct nfp_net_rx_ring *rx_ring; |
|---|
| .. | .. |
|---|
| 95 | 65 | rtnl_unlock(); |
|---|
| 96 | 66 | return 0; |
|---|
| 97 | 67 | } |
|---|
| 68 | +DEFINE_SHOW_ATTRIBUTE(nfp_rx_q); |
|---|
| 98 | 69 | |
|---|
| 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); |
|---|
| 103 | 72 | |
|---|
| 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) |
|---|
| 123 | 74 | { |
|---|
| 124 | 75 | struct nfp_net_r_vector *r_vec = file->private; |
|---|
| 125 | 76 | struct nfp_net_tx_ring *tx_ring; |
|---|
| .. | .. |
|---|
| 188 | 139 | return 0; |
|---|
| 189 | 140 | } |
|---|
| 190 | 141 | |
|---|
| 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) |
|---|
| 192 | 143 | { |
|---|
| 193 | | - return single_open(f, nfp_net_debugfs_tx_q_read, inode->i_private); |
|---|
| 144 | + return nfp_tx_q_show(file, data); |
|---|
| 194 | 145 | } |
|---|
| 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); |
|---|
| 203 | 147 | |
|---|
| 204 | 148 | void nfp_net_debugfs_vnic_add(struct nfp_net *nn, struct dentry *ddir) |
|---|
| 205 | 149 | { |
|---|
| .. | .. |
|---|
| 215 | 159 | else |
|---|
| 216 | 160 | strcpy(name, "ctrl-vnic"); |
|---|
| 217 | 161 | nn->debugfs_dir = debugfs_create_dir(name, ddir); |
|---|
| 218 | | - if (IS_ERR_OR_NULL(nn->debugfs_dir)) |
|---|
| 219 | | - return; |
|---|
| 220 | 162 | |
|---|
| 221 | 163 | /* Create queue debugging sub-tree */ |
|---|
| 222 | 164 | queues = debugfs_create_dir("queue", nn->debugfs_dir); |
|---|
| 223 | | - if (IS_ERR_OR_NULL(queues)) |
|---|
| 224 | | - return; |
|---|
| 225 | 165 | |
|---|
| 226 | 166 | rx = debugfs_create_dir("rx", queues); |
|---|
| 227 | 167 | tx = debugfs_create_dir("tx", queues); |
|---|
| 228 | 168 | 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; |
|---|
| 231 | 169 | |
|---|
| 232 | 170 | for (i = 0; i < min(nn->max_rx_rings, nn->max_r_vecs); i++) { |
|---|
| 233 | 171 | sprintf(name, "%d", i); |
|---|
| .. | .. |
|---|
| 246 | 184 | |
|---|
| 247 | 185 | struct dentry *nfp_net_debugfs_device_add(struct pci_dev *pdev) |
|---|
| 248 | 186 | { |
|---|
| 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); |
|---|
| 259 | 188 | } |
|---|
| 260 | 189 | |
|---|
| 261 | 190 | void nfp_net_debugfs_dir_clean(struct dentry **dir) |
|---|