[PATCH v3 1/1] ltq-vdsl-app: extent dsl metrics with boolean power and line states

Florian Eckert fe at dev.tdt.de
Tue Apr 6 13:49:45 BST 2021


With the old ubus dsl API, the numbers for the individual line_states and
power_states were also returned. These were not ported to the new DSL
C-API. This commit changes the following JSON output.

Instead of outputting the "line_state" and "power_state" numbers directly, the
values is now printed as boolean. This has the advantage that the
internal numbers are not shown, which can change in the future.

* current JSON output for state:
"state": "Showtime with TC-Layer sync"

* new JSON output for state:
"line_state": {
    "exception": false,
    "idle": false,
    "silent": false,
    "handshake": false,
    "full-init": false,
    "showtime-without-sync": false,
    "showtime-with-sync": true,
    "resync": false,
    "not-initialized": false,
    "string": "Showtime with TC-Layer sync"
},

* current JSON output for power_state:
"power_state": "L0 - Synchronized"

* new JSON outpug for power_state:
"power_state": {
    "NA": false,
    "L0": true,
    "L1": false,
    "L2": false,
    "L3": false,
    "string": "L0 - Synchronized"
}

Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 package/network/config/ltq-vdsl-app/Makefile  |  2 +-
 .../ltq-vdsl-app/src/src/dsl_cpe_ubus.c       | 32 ++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/package/network/config/ltq-vdsl-app/Makefile b/package/network/config/ltq-vdsl-app/Makefile
index 0823a0e7e9..f5c561078d 100644
--- a/package/network/config/ltq-vdsl-app/Makefile
+++ b/package/network/config/ltq-vdsl-app/Makefile
@@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=ltq-vdsl-app
 PKG_VERSION:=4.17.18.6
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 PKG_BASE_NAME:=dsl_cpe_control
 PKG_SOURCE:=$(PKG_BASE_NAME)_vrx-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=@OPENWRT
diff --git a/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c b/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c
index 8eefdfe4d5..2ab35ac056 100644
--- a/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c
+++ b/package/network/config/ltq-vdsl-app/src/src/dsl_cpe_ubus.c
@@ -306,6 +306,7 @@ static void version_information(int fd) {
 static void line_state(int fd) {
 	IOCTL(DSL_LineState_t, DSL_FIO_LINE_STATE_GET)
 
+	void *c;
 	const char *str;
 	switch (out.data.nLineState) {
 	STR_CASE(DSL_LINESTATE_NOT_INITIALIZED, "Not initialized")
@@ -351,8 +352,21 @@ static void line_state(int fd) {
 		str = NULL;
 		break;
 	};
-	if (str)
-		m_str("state", str);
+
+	if (str) {
+		c = blobmsg_open_table(&b, "line_state");
+		m_bool("exception", out.data.nLineState == DSL_LINESTATE_EXCEPTION);
+		m_bool("idle", out.data.nLineState == DSL_LINESTATE_IDLE);
+		m_bool("silent", out.data.nLineState == DSL_LINESTATE_SILENT);
+		m_bool("handshake", out.data.nLineState == DSL_LINESTATE_HANDSHAKE);
+		m_bool("full-init", out.data.nLineState == DSL_LINESTATE_FULL_INIT);
+		m_bool("showtime-without-sync", out.data.nLineState == DSL_LINESTATE_SHOWTIME_NO_SYNC);
+		m_bool("showtime-with-sync", out.data.nLineState == DSL_LINESTATE_SHOWTIME_TC_SYNC);
+		m_bool("resync", out.data.nLineState == DSL_LINESTATE_RESYNC);
+		m_bool("not-initialized", out.data.nLineState == DSL_LINESTATE_NOT_INITIALIZED);
+		m_str("string", str);
+		blobmsg_close_table(&b, c);
+	}
 
 	m_bool("up", out.data.nLineState == DSL_LINESTATE_SHOWTIME_TC_SYNC);
 }
@@ -377,6 +391,7 @@ static void g997_line_inventory(int fd) {
 static void g997_power_management_status(int fd) {
 	IOCTL(DSL_G997_PowerManagementStatus_t, DSL_FIO_G997_POWER_MANAGEMENT_STATUS_GET)
 
+	void *c;
 	const char *str;
 	switch (out.data.nPowerManagementStatus) {
 	STR_CASE(DSL_G997_PMS_NA, "Power management state is not available")
@@ -388,8 +403,17 @@ static void g997_power_management_status(int fd) {
 		str = NULL;
 		break;
 	};
-	if (str)
-		m_str("power_state", str);
+
+	if (str) {
+		c = blobmsg_open_table(&b, "power_state");
+		m_bool("NA", out.data.nPowerManagementStatus == DSL_G997_PMS_NA);
+		m_bool("L0", out.data.nPowerManagementStatus == DSL_G997_PMS_L0);
+		m_bool("L1", out.data.nPowerManagementStatus == DSL_G997_PMS_L1);
+		m_bool("L2", out.data.nPowerManagementStatus == DSL_G997_PMS_L2);
+		m_bool("L3", out.data.nPowerManagementStatus == DSL_G997_PMS_L3);
+		m_str("string", str);
+		blobmsg_close_table(&b, c);
+	}
 }
 
 static void g997_xtu_system_enabling(int fd, standard_t *standard) {
-- 
2.20.1




More information about the openwrt-devel mailing list