From 406b98549ceda39b336de4b6dd2fb9f620f4cd2f Mon Sep 17 00:00:00 2001
From: Adam Wujek <dev_public@wujek.eu>
Date: Thu, 4 May 2023 17:05:01 +0200
Subject: [PATCH] [FEATURE: #275] userspace/tools: Add informing about
 unrecognized SFP in wr_mon

From now, the first character (+/-) informs whether SFP is in the DB.

Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
 userspace/tools/wr_mon.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/userspace/tools/wr_mon.c b/userspace/tools/wr_mon.c
index aeb2437c2..53b487697 100644
--- a/userspace/tools/wr_mon.c
+++ b/userspace/tools/wr_mon.c
@@ -808,9 +808,8 @@ void show_ports(int hal_alive, int ppsi_alive)
 
 		print_gm_info();
 
-		term_cprintf(C_CYAN, "----- HAL ---|---------------------------------- PPSI --------------------------------------------------------\n");
-		term_cprintf(C_CYAN, " Iface| Freq |Inst|     Name     |   Config   | MAC of peer port  |    PTP/EXT/PDETECT States    | Pro | VLANs\n");
-		term_cprintf(C_CYAN, "------+------+----+--------------+------------+-------------------+------------------------------+-----+------\n");
+		term_cprintf(C_CYAN, "----- HAL ----|---------------------------------- PPSI --------------------------------------------------------\n");
+		term_cprintf(C_CYAN, " Iface | Freq |Inst|     Name     |   Config   | MAC of peer port  |    PTP/EXT/PDETECT States    | Pro | VLANs\n");
 
 	}
 	if (mode & (SHOW_SLAVE_PORTS|SHOW_MASTER_PORTS)) {
@@ -831,11 +830,15 @@ void show_ports(int hal_alive, int ppsi_alive)
 			continue;
 
 		if (mode == SHOW_GUI) {
+			/* check if SFP is in database */
+			if (!(port_state->calib.sfp.flags & SFP_FLAG_IN_DB))
+				term_cprintf(C_BLUE, "-");
 			/* check if link is up */
 			if (state_up(port_state))
-				term_cprintf(C_GREEN, " %-5s", if_name);
-			else
-				term_cprintf(C_RED, "*%-5s", if_name);
+				term_cprintf(C_GREEN, "%s %-5s", port_state->calib.sfp.flags & SFP_FLAG_IN_DB ? "+" : "", if_name);
+			else {
+				term_cprintf(C_RED, "%s*%-5s", port_state->calib.sfp.flags & SFP_FLAG_IN_DB ? "+" : "", if_name);
+			}
 			term_cprintf(C_CYAN, "| ");
 			if (port_state->locked)
 				term_cprintf(C_GREEN, "Lock ");
@@ -1010,8 +1013,9 @@ void show_ports(int hal_alive, int ppsi_alive)
 		}
 	}
 	if (mode == SHOW_GUI) {
-		term_cprintf(C_BLUE, "Pro - Protocol mapping: V-Ethernet over "
-			     "VLAN; U-UDP; R-Ethernet\n");
+		term_cprintf(C_BLUE, "Iface: +/- SFP in DB; "
+			     "Pro - Protocol mapping: V-Ethernet over VLAN, "
+			     "U-UDP, R-Ethernet\n");
 	}
 }
 
-- 
GitLab