Commit fc4ecaee authored by Murali Karicheri's avatar Murali Karicheri Committed by David S. Miller
Browse files

net: hsr: add debugfs support for display node list



This adds a debugfs interface to allow display the nodes learned
by the hsr master.

Signed-off-by: default avatarMurali Karicheri <m-karicheri2@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e7623bd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ obj-$(CONFIG_HSR) += hsr.o

hsr-y			:= hsr_main.o hsr_framereg.o hsr_device.o \
			   hsr_netlink.o hsr_slave.o hsr_forward.o
hsr-$(CONFIG_DEBUG_FS) += hsr_prp_debugfs.o
+5 −0
Original line number Diff line number Diff line
@@ -354,6 +354,8 @@ static void hsr_dev_destroy(struct net_device *hsr_dev)

	hsr = netdev_priv(hsr_dev);

	hsr_prp_debugfs_term(hsr);

	rtnl_lock();
	hsr_for_each_port(hsr, port)
		hsr_del_port(port);
@@ -483,6 +485,9 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
		goto fail;

	mod_timer(&hsr->prune_timer, jiffies + msecs_to_jiffies(PRUNE_PERIOD));
	res = hsr_prp_debugfs_init(hsr);
	if (res)
		goto fail;

	return 0;

+0 −12
Original line number Diff line number Diff line
@@ -18,18 +18,6 @@
#include "hsr_framereg.h"
#include "hsr_netlink.h"

struct hsr_node {
	struct list_head	mac_list;
	unsigned char		macaddress_A[ETH_ALEN];
	unsigned char		macaddress_B[ETH_ALEN];
	/* Local slave through which AddrB frames are received from this node */
	enum hsr_port_type	addr_B_port;
	unsigned long		time_in[HSR_PT_PORTS];
	bool			time_in_stale[HSR_PT_PORTS];
	u16			seq_out[HSR_PT_PORTS];
	struct rcu_head		rcu_head;
};

/*	TODO: use hash lists for mac addresses (linux/jhash.h)?    */

/* seq_nr_after(a, b) - return true if a is after (higher in sequence than) b,
+12 −0
Original line number Diff line number Diff line
@@ -48,4 +48,16 @@ int hsr_get_node_data(struct hsr_priv *hsr,
		      int *if2_age,
		      u16 *if2_seq);

struct hsr_node {
	struct list_head	mac_list;
	unsigned char		macaddress_A[ETH_ALEN];
	unsigned char		macaddress_B[ETH_ALEN];
	/* Local slave through which AddrB frames are received from this node */
	enum hsr_port_type	addr_B_port;
	unsigned long		time_in[HSR_PT_PORTS];
	bool			time_in_stale[HSR_PT_PORTS];
	u16			seq_out[HSR_PT_PORTS];
	struct rcu_head		rcu_head;
};

#endif /* __HSR_FRAMEREG_H */
+17 −0
Original line number Diff line number Diff line
@@ -163,6 +163,10 @@ struct hsr_priv {
	u8 prot_version;		/* Indicate if HSRv0 or HSRv1. */
	spinlock_t seqnr_lock;			/* locking for sequence_nr */
	unsigned char		sup_multicast_addr[ETH_ALEN];
#ifdef	CONFIG_DEBUG_FS
	struct dentry *node_tbl_root;
	struct dentry *node_tbl_file;
#endif
};

#define hsr_for_each_port(hsr, port) \
@@ -179,4 +183,17 @@ static inline u16 hsr_get_skb_sequence_nr(struct sk_buff *skb)
	return ntohs(hsr_ethhdr->hsr_tag.sequence_nr);
}

#if IS_ENABLED(CONFIG_DEBUG_FS)
int hsr_prp_debugfs_init(struct hsr_priv *priv);
void hsr_prp_debugfs_term(struct hsr_priv *priv);
#else
static inline int hsr_prp_debugfs_init(struct hsr_priv *priv)
{
	return 0;
}

static inline void hsr_prp_debugfs_term(struct hsr_priv *priv)
{}
#endif

#endif /*  __HSR_PRIVATE_H */
Loading