Openwrt/package/network/config/ltq-vdsl-app/patches/300-ubus.patch

51 lines
1.4 KiB
Diff
Raw Normal View History

ltq-vdsl-app: add ubus support to get metrics Add a 'dsl' ubus object with a 'metrics' function to replace the expensive shell parsing done by /etc/init.d/dsl_control [dsl|luci]stat. All metrics are gathered by using syscalls. An additional thread is started to handle ubus events. $ time /etc/init.d/dsl_control dslstat real 0m 2.66s user 0m 0.90s sys 0m 1.76s $ time ubus call dsl metrics real 0m 0.02s user 0m 0.00s sys 0m 0.01s Example output: { "api_version": "4.17.18.6", "firmware_version": "5.8.1.5.0.7", "chipset": "Lantiq-VRX200", "driver_version": "1.5.17.6", "state": "Showtime with TC-Layer sync", "up": true, "uptime": 3891, "atu_c": { "vendor_id": [ 181, 0, 66, 68, 67, 77, 178, 26 ], "vendor": "Broadcom 178.26", "system_vendor_id": [ 181, 0, 66, 68, 67, 77, 0, 0 ], "system_vendor": "Broadcom", "version": [ 49, 57, 46, 48, 46, 51, 53, 46, 50, 32, 86, 69, 95, 49, 49, 95 ], "serial": [ 65, 65, 49, 52, 52, 54, 70, 69, 48, 90, 87, 45, 48, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] }, "power_state": "L0 - Synchronized", "xtse": [ 0, 0, 0, 0, 0, 0, 0, 2 ], "annex": "B", "standard": "G.993.2", "profile": "17a", "mode": "G.993.2 (VDSL2, Profile 17a, with down- and upstream vectoring)", "upstream": { "vector": true, "trellis": true, "bitswap": true, "retx": true, "virtual_noise": false, "interleave_delay": 0, "data_rate": 31999000, "latn": 8.500000, "satn": 8.400000, "snr": 12.700000, "actps": -90.100000, "actatp": 13.400000, "attndr": 37180000 }, "downstream": { "vector": true, "trellis": true, "bitswap": true, "retx": true, "virtual_noise": false, "interleave_delay": 140, "data_rate": 89998000, "latn": 9.500000, "satn": 9.600000, "snr": 13.300000, "actps": -90.100000, "actatp": -1.600000, "attndr": 116315372 }, "errors": { "near": { "es": 1, "ses": 0, "loss": 3, "uas": 424, "lofs": 0, "fecs": 0, "hec": 0, "ibe": 0, "crc_p": 0, "crcp_p": 0, "cv_p": 0, "cvp_p": 0, "rx_corrupted": 27740, "rx_uncorrected_protected": 27010, "rx_retransmitted": 0, "rx_corrected": 730, "tx_retransmitted": 16222 }, "far": { "es": 242, "ses": 71, "loss": 0, "uas": 424, "lofs": 0, "fecs": 22687, "hec": 0, "ibe": 0, "crc_p": 0, "crcp_p": 0, "cv_p": 0, "cvp_p": 0, "rx_corrupted": 1383552, "rx_uncorrected_protected": 1220215, "rx_retransmitted": 0, "rx_corrected": 163337, "tx_retransmitted": 1574051 } } } Signed-off-by: Andre Heider <a.heider@gmail.com> Tested-by: Martin Schiller <ms@dev.tdt.de>
2021-01-26 08:00:48 +00:00
--- a/src/dsl_cpe_control.c
+++ b/src/dsl_cpe_control.c
@@ -177,6 +177,9 @@ extern DSL_Error_t DSL_CPE_Pipe_StaticRe
#endif /* INCLUDE_DSL_RESOURCE_STATISTICS*/
#endif
+extern void ubus_init();
+extern void ubus_deinit();
+
DSL_char_t *g_sFirmwareName1 = DSL_NULL;
DSL_FirmwareFeatures_t g_nFwFeatures1 = {DSL_FW_XDSLMODE_CLEANED, DSL_FW_XDSLFEATURE_CLEANED,
DSL_FW_XDSLFEATURE_CLEANED};
@@ -6759,6 +6762,8 @@ DSL_int_t dsl_cpe_daemon (
signal (SIGTERM, DSL_CPE_TerminationHandler);
#endif /* RTEMS*/
+ ubus_init();
+
/* Open DSL_CPE_MAX_DSL_ENTITIES devices*/
for (nDevice = 0; nDevice < DSL_CPE_MAX_DSL_ENTITIES; nDevice++)
{
@@ -7213,6 +7218,7 @@ DSL_int_t dsl_cpe_daemon (
#endif /* INCLUDE_DSL_CPE_CLI_SUPPORT */
DSL_CPE_CONTROL_EXIT:
+ ubus_deinit();
#ifdef INCLUDE_DSL_BONDING
DSL_CPE_BND_Stop((DSL_CPE_BND_Context_t*)pCtrlCtx->pBnd);
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,7 +11,7 @@ else
dsl_cpe_control_common_ldflags =
endif
-dsl_cpe_control_LDADD = -lpthread -lrt
+dsl_cpe_control_LDADD = -lpthread -lrt -lubox -lubus
if INCLUDE_DSL_CPE_DTI_SUPPORT
dsl_cpe_control_LDADD += -ldti_agent
@@ -66,7 +66,8 @@ dsl_cpe_control_SOURCES = \
dsl_cpe_control.c \
dsl_cpe_init_cfg.c \
dsl_cpe_linux.c \
- dsl_cpe_debug.c
+ dsl_cpe_debug.c \
+ dsl_cpe_ubus.c
dsl_cpe_control_SOURCES += \
$(dsl_cpe_control_dti_sources)