lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171108034911.16382-5-f.fainelli@gmail.com>
Date:   Tue,  7 Nov 2017 19:49:11 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     netdev@...r.kernel.org
Cc:     davem@...emloft.net, andrew@...n.ch, rmk+kernel@...linux.org.uk,
        Florian Fainelli <f.fainelli@...il.com>
Subject: [PATCH net-next 4/4] net: phy: sfp: Pretty print state machine events

Pretty print the entry and exit of the state machine by using human readable
strings.

Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
 drivers/net/phy/sfp.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c
index e4662bc58c01..8f938404e8ba 100644
--- a/drivers/net/phy/sfp.c
+++ b/drivers/net/phy/sfp.c
@@ -45,6 +45,18 @@ enum sfp_event_state {
 	SFP_E_TIMEOUT,
 };
 
+static const char *sfp_even_to_str[] = {
+	"insert",
+	"remove",
+	"device down",
+	"device up",
+	"TX fault",
+	"TX clear",
+	"LOS high",
+	"LOS low",
+	"timeout"
+};
+
 enum sfp_mod_state {
 	SFP_MOD_EMPTY = 0,
 	SFP_MOD_PROBE,
@@ -52,11 +64,23 @@ enum sfp_mod_state {
 	SFP_MOD_ERROR,
 };
 
+static const char *sfp_mod_state_to_str[] = {
+	"empty",
+	"probe",
+	"present",
+	"error",
+};
+
 enum sfp_dev_state {
 	SFP_DEV_DOWN = 0,
 	SFP_DEV_UP,
 };
 
+static const char *sfp_dev_state_to_str[] = {
+	"UP",
+	"DOWN",
+};
+
 enum sfp_sm_state {
 	SFP_S_DOWN = 0,
 	SFP_S_INIT,
@@ -67,6 +91,16 @@ enum sfp_sm_state {
 	SFP_S_TX_DISABLE,
 };
 
+static const char *sfp_state_to_str[] = {
+	"down",
+	"init",
+	"wait LOS",
+	"link UP",
+	"TX fault",
+	"re-initialization",
+	"TX disable",
+};
+
 static const char *gpio_of_names[] = {
 	"mod-def0",
 	"los",
@@ -502,8 +536,10 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
 {
 	mutex_lock(&sfp->sm_mutex);
 
-	dev_dbg(sfp->dev, "SM: enter %u:%u:%u event %u\n",
-		sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state, event);
+	dev_dbg(sfp->dev, "SM: enter %s:%s:%s event: %s\n",
+		sfp_mod_state_to_str[sfp->sm_mod_state],
+		sfp_dev_state_to_str[sfp->sm_dev_state],
+		sfp_state_to_str[sfp->sm_state], sfp_even_to_str[event]);
 
 	/* This state machine tracks the insert/remove state of
 	 * the module, and handles probing the on-board EEPROM.
@@ -632,8 +668,10 @@ static void sfp_sm_event(struct sfp *sfp, unsigned int event)
 		break;
 	}
 
-	dev_dbg(sfp->dev, "SM: exit %u:%u:%u\n",
-		sfp->sm_mod_state, sfp->sm_dev_state, sfp->sm_state);
+	dev_dbg(sfp->dev, "SM: exit %s:%s:%s\n",
+		sfp_mod_state_to_str[sfp->sm_mod_state],
+		sfp_dev_state_to_str[sfp->sm_dev_state],
+		sfp_state_to_str[sfp->sm_state]);
 
 	mutex_unlock(&sfp->sm_mutex);
 }
-- 
2.14.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ