20 #include <linux/module.h>
72 spin_unlock_irqrestore(&bnad->bna_lock, flags);
78 pr_warn(
"bnad %s: Failed to collect fwtrc\n",
89 bnad_debugfs_open_fwsave(
struct inode *inode,
struct file *file)
113 spin_unlock_irqrestore(&bnad->bna_lock, flags);
119 pr_warn(
"bna %s: Failed to collect fwsave\n",
130 bnad_debugfs_open_reg(
struct inode *inode,
struct file *file)
146 bnad_get_debug_drvinfo(
struct bnad *bnad,
void *
buffer,
u32 len)
150 unsigned long flags = 0;
156 spin_unlock_irqrestore(&bnad->bna_lock, flags);
160 fcomp.comp_status = 0;
161 init_completion(&fcomp.comp);
166 spin_unlock_irqrestore(&bnad->bna_lock, flags);
169 spin_unlock_irqrestore(&bnad->bna_lock, flags);
174 fcomp.comp_status = 0;
175 init_completion(&fcomp.comp);
180 spin_unlock_irqrestore(&bnad->bna_lock, flags);
183 spin_unlock_irqrestore(&bnad->bna_lock, flags);
191 bnad_debugfs_open_drvinfo(
struct inode *inode,
struct file *file)
211 rc = bnad_get_debug_drvinfo(bnad, drv_info->
debug_buffer,
219 pr_warn(
"bna %s: Failed to collect drvinfo\n",
231 bnad_debugfs_lseek(
struct file *file, loff_t
offset,
int orig)
262 bnad_debugfs_read(
struct file *file,
char __user *
buf,
263 size_t nbytes, loff_t *pos)
274 #define BFA_REG_CT_ADDRSZ (0x40000)
275 #define BFA_REG_CB_ADDRSZ (0x20000)
276 #define BFA_REG_ADDRSZ(__ioc) \
277 ((u32)(bfa_asic_id_ctc(bfa_ioc_devid(__ioc)) ? \
278 BFA_REG_CT_ADDRSZ : BFA_REG_CB_ADDRSZ))
279 #define BFA_REG_ADDRMSK(__ioc) (BFA_REG_ADDRSZ(__ioc) - 1)
290 area = (offset >> 15) & 0x7;
293 if ((offset + (len<<2)) > 0x8000)
295 }
else if (area == 0x1) {
297 if ((offset + (len<<2)) > 0x10000)
308 bnad_debugfs_read_regrd(
struct file *file,
char __user *buf,
309 size_t nbytes, loff_t *pos)
312 struct bnad *bnad = (
struct bnad *)regrd_debug->
i_private;
321 if ((*pos + nbytes) >= bnad->
reglen) {
331 bnad_debugfs_write_regrd(
struct file *file,
const char __user *buf,
332 size_t nbytes, loff_t *ppos)
335 struct bnad *bnad = (
struct bnad *)regrd_debug->
i_private;
337 int addr, len, rc,
i;
353 rc =
sscanf(kern_buf,
"%x:%x", &addr, &len);
355 pr_warn(
"bna %s: Failed to read user buffer\n",
375 rc = bna_reg_offset_check(
ioc, addr, len);
377 pr_warn(
"bna %s: Failed reg offset check\n",
388 for (
i = 0;
i < len;
i++) {
393 spin_unlock_irqrestore(&bnad->bna_lock, flags);
399 bnad_debugfs_write_regwr(
struct file *file,
const char __user *buf,
400 size_t nbytes, loff_t *ppos)
403 struct bnad *bnad = (
struct bnad *)debug->
i_private;
420 rc =
sscanf(kern_buf,
"%x:%x", &addr, &
val);
422 pr_warn(
"bna %s: Failed to read user buffer\n",
432 rc = bna_reg_offset_check(
ioc, addr, 1);
434 pr_warn(
"bna %s: Failed reg offset check\n",
442 spin_unlock_irqrestore(&bnad->bna_lock, flags);
448 bnad_debugfs_release(
struct inode *inode,
struct file *file)
461 bnad_debugfs_buffer_release(
struct inode *inode,
struct file *file)
478 .open = bnad_debugfs_open_fwtrc,
479 .llseek = bnad_debugfs_lseek,
480 .read = bnad_debugfs_read,
481 .release = bnad_debugfs_buffer_release,
486 .open = bnad_debugfs_open_fwsave,
487 .llseek = bnad_debugfs_lseek,
488 .read = bnad_debugfs_read,
489 .release = bnad_debugfs_buffer_release,
494 .open = bnad_debugfs_open_reg,
495 .llseek = bnad_debugfs_lseek,
496 .read = bnad_debugfs_read_regrd,
497 .write = bnad_debugfs_write_regrd,
498 .release = bnad_debugfs_release,
503 .open = bnad_debugfs_open_reg,
504 .llseek = bnad_debugfs_lseek,
505 .write = bnad_debugfs_write_regwr,
506 .release = bnad_debugfs_release,
511 .open = bnad_debugfs_open_drvinfo,
512 .llseek = bnad_debugfs_lseek,
513 .read = bnad_debugfs_read,
514 .release = bnad_debugfs_buffer_release,
531 static struct dentry *bna_debugfs_root;
532 static atomic_t bna_debugfs_port_count;
543 if (!bna_debugfs_root) {
546 if (!bna_debugfs_root) {
547 pr_warn(
"BNA: debugfs root dir creation failed\n");
553 snprintf(name,
sizeof(name),
"pci_dev:%s", pci_name(bnad->
pcidev));
558 pr_warn(
"bna pci_dev %s: root dir creation failed\n",
565 for (i = 0; i <
ARRAY_SIZE(bnad_debugfs_files); i++) {
566 file = &bnad_debugfs_files[
i];
575 "BNA pci_dev:%s: create %s entry failed\n",
589 for (i = 0; i <
ARRAY_SIZE(bnad_debugfs_files); i++) {
606 bna_debugfs_root =
NULL;