~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/hsr/hsr_debugfs.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * debugfs code for HSR & PRP
  4  * Copyright (C) 2019 Texas Instruments Incorporated
  5  *
  6  * Author(s):
  7  *      Murali Karicheri <m-karicheri2@ti.com>
  8  */
  9 #include <linux/module.h>
 10 #include <linux/errno.h>
 11 #include <linux/debugfs.h>
 12 #include "hsr_main.h"
 13 #include "hsr_framereg.h"
 14 
 15 static struct dentry *hsr_debugfs_root_dir;
 16 
 17 /* hsr_node_table_show - Formats and prints node_table entries */
 18 static int
 19 hsr_node_table_show(struct seq_file *sfp, void *data)
 20 {
 21         struct hsr_priv *priv = (struct hsr_priv *)sfp->private;
 22         struct hsr_node *node;
 23 
 24         seq_printf(sfp, "Node Table entries for (%s) device\n",
 25                    (priv->prot_version == PRP_V1 ? "PRP" : "HSR"));
 26         seq_puts(sfp, "MAC-Address-A,    MAC-Address-B,    time_in[A], ");
 27         seq_puts(sfp, "time_in[B], Address-B port, ");
 28         if (priv->prot_version == PRP_V1)
 29                 seq_puts(sfp, "SAN-A, SAN-B, DAN-P\n");
 30         else
 31                 seq_puts(sfp, "DAN-H\n");
 32 
 33         rcu_read_lock();
 34         list_for_each_entry_rcu(node, &priv->node_db, mac_list) {
 35                 /* skip self node */
 36                 if (hsr_addr_is_self(priv, node->macaddress_A))
 37                         continue;
 38                 seq_printf(sfp, "%pM ", &node->macaddress_A[0]);
 39                 seq_printf(sfp, "%pM ", &node->macaddress_B[0]);
 40                 seq_printf(sfp, "%10lx, ", node->time_in[HSR_PT_SLAVE_A]);
 41                 seq_printf(sfp, "%10lx, ", node->time_in[HSR_PT_SLAVE_B]);
 42                 seq_printf(sfp, "%14x, ", node->addr_B_port);
 43 
 44                 if (priv->prot_version == PRP_V1)
 45                         seq_printf(sfp, "%5x, %5x, %5x\n",
 46                                    node->san_a, node->san_b,
 47                                    (node->san_a == 0 && node->san_b == 0));
 48                 else
 49                         seq_printf(sfp, "%5x\n", 1);
 50         }
 51         rcu_read_unlock();
 52         return 0;
 53 }
 54 
 55 DEFINE_SHOW_ATTRIBUTE(hsr_node_table);
 56 
 57 void hsr_debugfs_rename(struct net_device *dev)
 58 {
 59         struct hsr_priv *priv = netdev_priv(dev);
 60         struct dentry *d;
 61 
 62         d = debugfs_rename(hsr_debugfs_root_dir, priv->node_tbl_root,
 63                            hsr_debugfs_root_dir, dev->name);
 64         if (IS_ERR(d))
 65                 netdev_warn(dev, "failed to rename\n");
 66         else
 67                 priv->node_tbl_root = d;
 68 }
 69 
 70 /* hsr_debugfs_init - create hsr node_table file for dumping
 71  * the node table
 72  *
 73  * Description:
 74  * When debugfs is configured this routine sets up the node_table file per
 75  * hsr device for dumping the node_table entries
 76  */
 77 void hsr_debugfs_init(struct hsr_priv *priv, struct net_device *hsr_dev)
 78 {
 79         struct dentry *de = NULL;
 80 
 81         de = debugfs_create_dir(hsr_dev->name, hsr_debugfs_root_dir);
 82         if (IS_ERR(de)) {
 83                 pr_err("Cannot create hsr debugfs directory\n");
 84                 return;
 85         }
 86 
 87         priv->node_tbl_root = de;
 88 
 89         de = debugfs_create_file("node_table", S_IFREG | 0444,
 90                                  priv->node_tbl_root, priv,
 91                                  &hsr_node_table_fops);
 92         if (IS_ERR(de)) {
 93                 pr_err("Cannot create hsr node_table file\n");
 94                 debugfs_remove(priv->node_tbl_root);
 95                 priv->node_tbl_root = NULL;
 96                 return;
 97         }
 98 }
 99 
100 /* hsr_debugfs_term - Tear down debugfs intrastructure
101  *
102  * Description:
103  * When Debugfs is configured this routine removes debugfs file system
104  * elements that are specific to hsr
105  */
106 void
107 hsr_debugfs_term(struct hsr_priv *priv)
108 {
109         debugfs_remove_recursive(priv->node_tbl_root);
110         priv->node_tbl_root = NULL;
111 }
112 
113 void hsr_debugfs_create_root(void)
114 {
115         hsr_debugfs_root_dir = debugfs_create_dir("hsr", NULL);
116         if (IS_ERR(hsr_debugfs_root_dir)) {
117                 pr_err("Cannot create hsr debugfs root directory\n");
118                 hsr_debugfs_root_dir = NULL;
119         }
120 }
121 
122 void hsr_debugfs_remove_root(void)
123 {
124         /* debugfs_remove() internally checks NULL and ERROR */
125         debugfs_remove(hsr_debugfs_root_dir);
126 }
127 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php