|
|
@@ -73,7 +73,7 @@ hsr_prp_node_table_open(struct inode *inode, struct file *filp)
|
|
|
return single_open(filp, hsr_prp_node_table_show, inode->i_private);
|
|
|
}
|
|
|
|
|
|
-static const struct file_operations hsr_prp_fops = {
|
|
|
+static const struct file_operations hsr_prp_node_table_fops = {
|
|
|
.owner = THIS_MODULE,
|
|
|
.open = hsr_prp_node_table_open,
|
|
|
.read = seq_read,
|
|
|
@@ -81,37 +81,112 @@ static const struct file_operations hsr_prp_fops = {
|
|
|
.release = single_release,
|
|
|
};
|
|
|
|
|
|
-/* hsr_prp_debugfs_init - create hsr node_table file for dumping
|
|
|
- * the node table
|
|
|
+/* hsr_prp_stats_show - Formats and prints stats in the device
|
|
|
+ */
|
|
|
+static int
|
|
|
+hsr_prp_stats_show(struct seq_file *sfp, void *data)
|
|
|
+{
|
|
|
+ struct hsr_prp_priv *priv = (struct hsr_prp_priv *)sfp->private;
|
|
|
+ struct hsr_prp_port *master;
|
|
|
+
|
|
|
+ rcu_read_lock();
|
|
|
+ master = hsr_prp_get_port(priv, HSR_PRP_PT_MASTER);
|
|
|
+ rcu_read_unlock();
|
|
|
+
|
|
|
+ seq_puts(sfp, "LRE Stats entries\n");
|
|
|
+ seq_printf(sfp, "cnt_tx_a = %d\n", priv->stats.cnt_tx_a);
|
|
|
+ seq_printf(sfp, "cnt_tx_b = %d\n", priv->stats.cnt_tx_b);
|
|
|
+ /* actually lre_tx_c is whatever sent to the application interface. So
|
|
|
+ * same as rx_packets
|
|
|
+ */
|
|
|
+ seq_printf(sfp, "cnt_tx_c = %ld\n", master->dev->stats.rx_packets);
|
|
|
+ seq_printf(sfp, "cnt_tx_sup = %d\n", priv->stats.cnt_tx_sup);
|
|
|
+ seq_printf(sfp, "cnt_rx_wrong_lan_a = %d\n",
|
|
|
+ priv->stats.cnt_rx_wrong_lan_a);
|
|
|
+ seq_printf(sfp, "cnt_rx_wrong_lan_b = %d\n",
|
|
|
+ priv->stats.cnt_rx_wrong_lan_b);
|
|
|
+ seq_printf(sfp, "cnt_rx_a = %d\n", priv->stats.cnt_rx_a);
|
|
|
+ seq_printf(sfp, "cnt_rx_b = %d\n", priv->stats.cnt_rx_b);
|
|
|
+ /* actually lre_rx_c is whatever received from the application
|
|
|
+ * interface, So same as tx_packets
|
|
|
+ */
|
|
|
+ seq_printf(sfp, "cnt_rx_c = %ld\n", master->dev->stats.tx_packets);
|
|
|
+ seq_printf(sfp, "cnt_rx_errors_a = %d\n", priv->stats.cnt_rx_errors_a);
|
|
|
+ seq_printf(sfp, "cnt_rx_errors_b = %d\n", priv->stats.cnt_rx_errors_b);
|
|
|
+ if (priv->prot_version <= HSR_V1) {
|
|
|
+ seq_printf(sfp, "cnt_own_rx_a = %d\n",
|
|
|
+ priv->stats.cnt_own_rx_a);
|
|
|
+ seq_printf(sfp, "cnt_own_rx_b = %d\n",
|
|
|
+ priv->stats.cnt_own_rx_b);
|
|
|
+ }
|
|
|
+ seq_puts(sfp, "\n");
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* hsr_prp_stats_open - open stats file
|
|
|
+ *
|
|
|
+ * Description:
|
|
|
+ * This routine opens a debugfs file stats of specific hsr or
|
|
|
+ * prp device
|
|
|
+ */
|
|
|
+static int
|
|
|
+hsr_prp_stats_open(struct inode *inode, struct file *filp)
|
|
|
+{
|
|
|
+ return single_open(filp, hsr_prp_stats_show, inode->i_private);
|
|
|
+}
|
|
|
+
|
|
|
+static const struct file_operations hsr_prp_stats_fops = {
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .open = hsr_prp_stats_open,
|
|
|
+ .read = seq_read,
|
|
|
+ .llseek = seq_lseek,
|
|
|
+ .release = single_release,
|
|
|
+};
|
|
|
+/* hsr_prp_debugfs_init - create hsr-prp node_table file for dumping
|
|
|
+ * the node table and lre stats
|
|
|
*
|
|
|
* Description:
|
|
|
* When debugfs is configured this routine sets up the node_table file per
|
|
|
- * hsr device for dumping the node_table entries
|
|
|
+ * hsr device for dumping the node_table entries and stats file for
|
|
|
+ * lre stats dump.
|
|
|
*/
|
|
|
-int hsr_prp_debugfs_init(struct hsr_prp_priv *priv, struct net_device *hsr_dev)
|
|
|
+int hsr_prp_debugfs_init(struct hsr_prp_priv *priv, struct net_device *ndev)
|
|
|
{
|
|
|
int rc = -1;
|
|
|
struct dentry *de = NULL;
|
|
|
|
|
|
- de = debugfs_create_dir(hsr_dev->name, NULL);
|
|
|
+ de = debugfs_create_dir(ndev->name, NULL);
|
|
|
if (!de) {
|
|
|
- pr_err("Cannot create hsr debugfs root\n");
|
|
|
+ netdev_err(ndev, "Cannot create debugfs root %s\n", ndev->name);
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
- priv->node_tbl_root = de;
|
|
|
+ priv->root_dir = de;
|
|
|
|
|
|
- de = debugfs_create_file("node_table", S_IFREG | 0444,
|
|
|
- priv->node_tbl_root, priv,
|
|
|
- &hsr_prp_fops);
|
|
|
+ de = debugfs_create_file("node_table", S_IFREG | 0444, priv->root_dir,
|
|
|
+ priv, &hsr_prp_node_table_fops);
|
|
|
if (!de) {
|
|
|
- pr_err("Cannot create hsr node_table directory\n");
|
|
|
- return rc;
|
|
|
+ netdev_err(ndev, "Cannot create hsr node_table directory\n");
|
|
|
+ goto error_nt;
|
|
|
}
|
|
|
priv->node_tbl_file = de;
|
|
|
|
|
|
+ de = debugfs_create_file("stats", S_IFREG | 0444, priv->root_dir, priv,
|
|
|
+ &hsr_prp_stats_fops);
|
|
|
+ if (!de) {
|
|
|
+ netdev_err(ndev, "Cannot create hsr-prp stats directory\n");
|
|
|
+ goto error_stats;
|
|
|
+ }
|
|
|
+ priv->stats_file = de;
|
|
|
+
|
|
|
return 0;
|
|
|
-}
|
|
|
+
|
|
|
+error_stats:
|
|
|
+ debugfs_remove(priv->node_tbl_file);
|
|
|
+error_nt:
|
|
|
+ debugfs_remove(priv->root_dir);
|
|
|
+ return -ENODEV;
|
|
|
+} /* end of hst_prp_debugfs_init */
|
|
|
|
|
|
/* hsr_prp_debugfs_term - Tear down debugfs intrastructure
|
|
|
*
|
|
|
@@ -124,6 +199,8 @@ hsr_prp_debugfs_term(struct hsr_prp_priv *priv)
|
|
|
{
|
|
|
debugfs_remove(priv->node_tbl_file);
|
|
|
priv->node_tbl_file = NULL;
|
|
|
- debugfs_remove(priv->node_tbl_root);
|
|
|
- priv->node_tbl_root = NULL;
|
|
|
+ debugfs_remove(priv->stats_file);
|
|
|
+ priv->stats_file = NULL;
|
|
|
+ debugfs_remove(priv->root_dir);
|
|
|
+ priv->root_dir = NULL;
|
|
|
}
|