From patchwork Sat Jan 28 19:45:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hoffmann X-Patchwork-Id: 1733342 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=DOdzLCww; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=3e8.eu header.i=@3e8.eu header.a=rsa-sha256 header.s=mail20211217 header.b=SC3tqvzw; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P44kg4416z23hg for ; Sun, 29 Jan 2023 06:48:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=iX07S3azYJDw6N2xzXydeObxGH2BCEcPX1P2HhsyO4M=; b=DOdzLCwwGuRm53 pXbA79KqwWaJpw514ImRwXDl1SqK7vc0lCXYmPcH76Lrjco+CsJgIYxgj2BA7I2yVNibnwkaUBlga yY9gWnjGkBH500QyPOkfnzepIvyrh6OjJRuOwstfba4DTpDyutRvoMNuLOE7rXj8SWuiH02ol6RQR 0g+fuOVaMnN9TsV/frjxr6Brm8OCVy9xm3veOMu7vuY8oFbIth5oM6Ul0eob6MecG4e2U5087tVCY 8TA6fd5IxXVCHa0SeC3xSeKWv6Mp7WUAbRlnlzUvqdq5gAi2A0cF+sl/x8f06N9MuM2oVdOYs2XRa qU0vv5Xkwym+kYLkpsPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLr96-000cYL-Jh; Sat, 28 Jan 2023 19:45:52 +0000 Received: from srv4.3e8.eu ([193.25.101.238]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLr90-000cXX-VK for openwrt-devel@lists.openwrt.org; Sat, 28 Jan 2023 19:45:50 +0000 Received: from localhost.localdomain (p200300c6cf286da049345befe3093af9.dip0.t-ipconnect.de [IPv6:2003:c6:cf28:6da0:4934:5bef:e309:3af9]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits)) (No client certificate requested) by srv4.3e8.eu (Postfix) with ESMTPSA id 46D3E600C7; Sat, 28 Jan 2023 20:45:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=3e8.eu; s=mail20211217; t=1674935140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=y3H6JC4rW9azUNWc7bFMaTWYYn3Oq1muFV4d/8jcfgo=; b=SC3tqvzw4BgapPV39d9zb+L8EG5CKMkpLUQ04xX0M7+3eLmVIAQp33HYzkWaPhbdq5GvSw wZMt+g6gOyFS3EYNHU+hjIB1mTIAr+RZlGzLQwJUQ/8EHa1dyt4fpZTM4VzGEpV3u1//RJ XMbOXwkWK4C88NVgeWnjgAstnnb6d/71AKYlNxLeGuY/CwtiyufvkU4NAqqj664nGk0MOL X9N6iEXMr24IANkd53VG393NimdiNgfqP7BIlSLNOrLs7lUzQawAyUz2ynrQwRoz1PdD3+ 2NSTCuDE1FAiMc5jDE5x6nqzZF/SHRlB3rrO2zEMsheVVKNT2fTW9t0F2iXrwA== From: Jan Hoffmann To: openwrt-devel@lists.openwrt.org Cc: Jan Hoffmann Subject: [PATCH] ltq-*-app: extend ubus metrics/statistics Date: Sat, 28 Jan 2023 20:45:24 +0100 Message-Id: <20230128194524.303730-1-jan@3e8.eu> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230128_114547_334445_75B73301 X-CRM114-Status: GOOD ( 13.80 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Expose a few additional useful values via ubus: - Channel error counters (CRC, FEC) - Retransmission counters (MINEFTR, LEFTRS) - Impulse noise protection level - Rate adaptation mode - OLR statistics (Bitswap, SRA, SOS) - Pilot tones - Upstream/do [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Expose a few additional useful values via ubus: - Channel error counters (CRC, FEC) - Retransmission counters (MINEFTR, LEFTRS) - Impulse noise protection level - Rate adaptation mode - OLR statistics (Bitswap, SRA, SOS) - Pilot tones - Upstream/downstream band information Signed-off-by: Jan Hoffmann --- Run-tested for ltq-vdsl-vr9-app and ltq-vdsl-vr11-app. Compile-tested for ltq-adsl-app. I have prepared patches to make use of some of these values in LuCI, which will be submitted later: https://github.com/janh/luci/tree/luci-mod-status-extend-dsl https://github.com/janh/luci/tree/luci-mod-dsl-pilot-tones package/network/config/ltq-adsl-app/Makefile | 2 +- .../network/config/ltq-vdsl-vr11-app/Makefile | 2 +- .../ltq-vdsl-vr9-app/src/src/dsl_cpe_ubus.c | 163 +++++++++++++++++- 3 files changed, 162 insertions(+), 5 deletions(-) diff --git a/package/network/config/ltq-adsl-app/Makefile b/package/network/config/ltq-adsl-app/Makefile index c4ddbf7089fc..472e3c0ed9c6 100644 --- a/package/network/config/ltq-adsl-app/Makefile +++ b/package/network/config/ltq-adsl-app/Makefile @@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=dsl_cpe_control_danube PKG_VERSION:=3.24.4.4 -PKG_RELEASE:=10 +PKG_RELEASE:=11 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_BUILD_DIR:=$(BUILD_DIR)/dsl_cpe_control-$(PKG_VERSION) PKG_SOURCE_URL:=@OPENWRT diff --git a/package/network/config/ltq-vdsl-vr11-app/Makefile b/package/network/config/ltq-vdsl-vr11-app/Makefile index 8639795458f6..bcbf41e65a15 100644 --- a/package/network/config/ltq-vdsl-vr11-app/Makefile +++ b/package/network/config/ltq-vdsl-vr11-app/Makefile @@ -9,7 +9,7 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=ltq-vdsl-vr11-app PKG_VERSION:=4.23.1 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_BASE_NAME:=dsl_cpe_control UGW_VERSION=8.5.2.10 diff --git a/package/network/config/ltq-vdsl-vr9-app/src/src/dsl_cpe_ubus.c b/package/network/config/ltq-vdsl-vr9-app/src/src/dsl_cpe_ubus.c index bf8a8b9c2c0d..77a1c67b6aeb 100644 --- a/package/network/config/ltq-vdsl-vr9-app/src/src/dsl_cpe_ubus.c +++ b/package/network/config/ltq-vdsl-vr9-app/src/src/dsl_cpe_ubus.c @@ -133,6 +133,17 @@ enum { PSTATE_MAP_L3, }; +/* These values are exported via ubus and backwards compability + * needs to be kept! + */ +enum { + RAMODE_MAP_UNKNOWN = -1, + RAMODE_MAP_MANUAL, + RAMODE_MAP_AT_INIT, + RAMODE_MAP_DYNAMIC, + RAMODE_MAP_DYNAMIC_SOS, +}; + static DSL_CPE_ThreadCtrl_t thread; static struct ubus_context *ctx; static struct blob_buf b; @@ -171,6 +182,15 @@ static inline void m_array(const char *id, const uint8_t *value, size_t len) { blobmsg_close_array(&b, c); } +static inline void m_array_u16(const char *id, const uint16_t *value, size_t len) { + void *c = blobmsg_open_array(&b, id); + + for (size_t i = 0; i < len; ++i) + blobmsg_add_u16(&b, "", value[i]); + + blobmsg_close_array(&b, c); +} + static void m_vendor(const char *id, const uint8_t *value) { // ITU-T T.35: U.S. if (U16(value[0], value[1]) != 0xb500) @@ -418,6 +438,31 @@ static void g997_line_inventory(int fd) { m_array("serial", out.data.SerialNumber, DSL_G997_LI_MAXLEN_SERIAL); } +static void pilot_tones_status(int fd) { +#ifndef INCLUDE_DSL_CPE_API_DANUBE + IOCTL(DSL_PilotTonesStatus_t, DSL_FIO_PILOT_TONES_STATUS_GET); + + m_array_u16("pilot_tones", out.data.nPilotTone, out.data.nNumData); +#endif +} + +static void band_border_status(int fd, DSL_AccessDir_t direction) { + IOCTL(DSL_BandBorderStatus_t, DSL_FIO_BAND_BORDER_STATUS_GET); + + void *c, *c2; + + c = blobmsg_open_array(&b, "limits"); + + for (size_t i = 0; i < out.data.nNumData; i++) { + c2 = blobmsg_open_table(&b, ""); + blobmsg_add_u16(&b, "first", out.data.nBandLimits[i].nFirstToneIndex); + blobmsg_add_u16(&b, "last", out.data.nBandLimits[i].nLastToneIndex); + blobmsg_close_table(&b, c2); + } + + blobmsg_close_array(&b, c); +} + static void g977_get_bit_allocation(int fd, DSL_AccessDir_t direction) { IOCTL_DIR(DSL_G997_BitAllocationNsc_t, DSL_FIO_G997_BIT_ALLOCATION_NSC_GET, direction); @@ -639,19 +684,46 @@ static void band_plan_status(int fd, profile_t *profile) { #endif } -static void line_feature_config(int fd, DSL_AccessDir_t direction) { +static void line_feature_config(int fd, DSL_AccessDir_t direction, bool *retx) { IOCTL_DIR(DSL_LineFeature_t, DSL_FIO_LINE_FEATURE_STATUS_GET, direction) m_bool("trellis", out.data.bTrellisEnable); m_bool("bitswap", out.data.bBitswapEnable); m_bool("retx", out.data.bReTxEnable); m_bool("virtual_noise", out.data.bVirtualNoiseSupport); + + *retx = out.data.bReTxEnable; +} + +static void g997_rate_adaptation_status(int fd, DSL_AccessDir_t direction) { +#ifndef INCLUDE_DSL_CPE_API_DANUBE + IOCTL_DIR(DSL_G997_RateAdaptationStatus_t, DSL_FIO_G997_RATE_ADAPTATION_STATUS_GET, direction); + + int map = RAMODE_MAP_UNKNOWN; + const char *str; + switch (out.data.RA_MODE) { + STR_CASE_MAP(DSL_G997_RA_MODE_MANUAL, "Manual", RAMODE_MAP_MANUAL) + STR_CASE_MAP(DSL_G997_RA_MODE_AT_INIT, "At initialization", RAMODE_MAP_AT_INIT) + STR_CASE_MAP(DSL_G997_RA_MODE_DYNAMIC, "Dynamic", RAMODE_MAP_DYNAMIC) + STR_CASE_MAP(DSL_G997_RA_MODE_DYNAMIC_SOS, "Dynamic with SOS", RAMODE_MAP_DYNAMIC_SOS) + default: + str = NULL; + break; + }; + + if (str) + m_str("ra_mode", str); + + if (map != PSTATE_MAP_UNKNOWN) + m_u32("ra_mode_num", map); +#endif } static void g997_channel_status(int fd, DSL_AccessDir_t direction) { IOCTL_DIR(DSL_G997_ChannelStatus_t, DSL_FIO_G997_CHANNEL_STATUS_GET, direction); m_u32("interleave_delay", out.data.ActualInterleaveDelay * 10); + m_double("inp", (double)out.data.ActualImpulseNoiseProtection / 10); #ifndef INCLUDE_DSL_CPE_API_DANUBE // prefer ACTNDR, see comments in drv_dsl_cpe_api_g997.h m_u32("data_rate", out.data.ActualNetDataRate); @@ -672,6 +744,41 @@ static void g997_line_status(int fd, DSL_AccessDir_t direction) { m_u32("attndr", out.data.ATTNDR); } +static void pm_retx_counters_showtime(int fd, DSL_XTUDir_t direction) { +#ifdef INCLUDE_DSL_CPE_PM_RETX_COUNTERS + IOCTL_DIR(DSL_PM_ReTxCounters_t, DSL_FIO_PM_RETX_COUNTERS_SHOWTIME_GET, direction); + + m_u32("mineftr", out.data.nEftrMin); +#endif +} + +#ifndef INCLUDE_DSL_CPE_API_DANUBE +static void olr_statistics(int fd, DSL_AccessDir_t direction) { + IOCTL_DIR(DSL_OlrStatistics_t, DSL_FIO_OLR_STATISTICS_GET, direction) + + void *c = blobmsg_open_table(&b, "bitswap"); + m_u32("requested", out.data.nBitswapRequested + out.data.nBitswapRequested); + m_u32("executed", out.data.nBitswapExecuted); + m_u32("rejected", out.data.nBitswapRejected); + m_u32("timeout", out.data.nBitswapTimeout); + blobmsg_close_table(&b, c); + + c = blobmsg_open_table(&b, "sra"); + m_u32("requested", out.data.nSraRequested); + m_u32("executed", out.data.nSraExecuted); + m_u32("rejected", out.data.nSraRejected); + m_u32("timeout", out.data.nSraTimeout); + blobmsg_close_table(&b, c); + + c = blobmsg_open_table(&b, "sos"); + m_u32("requested", out.data.nSosRequested); + m_u32("executed", out.data.nSosExecuted); + m_u32("rejected", out.data.nSosRejected); + m_u32("timeout", out.data.nSosTimeout); + blobmsg_close_table(&b, c); +} +#endif + static void pm_line_sec_counters_total(int fd, DSL_XTUDir_t direction) { IOCTL_DIR(DSL_PM_LineSecCountersTotal_t, DSL_FIO_PM_LINE_SEC_COUNTERS_TOTAL_GET, direction) @@ -685,6 +792,21 @@ static void pm_line_sec_counters_total(int fd, DSL_XTUDir_t direction) { #endif } +static void pm_retx_counters_total(int fd, DSL_XTUDir_t direction) { +#ifdef INCLUDE_DSL_CPE_PM_RETX_COUNTERS + IOCTL_DIR(DSL_PM_ReTxCountersTotal_t, DSL_FIO_PM_RETX_COUNTERS_TOTAL_GET, direction); + + m_u32("leftrs", out.data.nLeftr); +#endif +} + +static void pm_channel_counters_total(int fd, DSL_XTUDir_t direction) { + IOCTL_DIR(DSL_PM_ChannelCountersTotal_t, DSL_FIO_PM_CHANNEL_COUNTERS_TOTAL_GET, direction); + + m_u32("cv_c", out.data.nCodeViolations); + m_u32("fec_c", out.data.nFEC); +} + static void pm_data_path_counters_total(int fd, DSL_XTUDir_t direction) { IOCTL_DIR(DSL_PM_DataPathCountersTotal_t, DSL_FIO_PM_DATA_PATH_COUNTERS_TOTAL_GET, direction); @@ -810,6 +932,17 @@ static int line_statistics(struct ubus_context *ctx, struct ubus_object *obj, blob_buf_init(&b, 0); + pilot_tones_status(fd); + + c = blobmsg_open_table(&b, "bands"); + c2 = blobmsg_open_table(&b, "downstream"); + band_border_status(fd, DSL_DOWNSTREAM); + blobmsg_close_table(&b, c2); + c2 = blobmsg_open_table(&b, "upstream"); + band_border_status(fd, DSL_UPSTREAM); + blobmsg_close_table(&b, c2); + blobmsg_close_table(&b, c); + c = blobmsg_open_table(&b, "bits"); c2 = blobmsg_open_table(&b, "downstream"); g977_get_bit_allocation(fd, DSL_DOWNSTREAM); @@ -862,6 +995,7 @@ static int metrics(struct ubus_context *ctx, struct ubus_object *obj, standard_t standard = STD_UNKNOWN; profile_t profile = PROFILE_UNKNOWN; vector_t vector = VECTOR_UNKNOWN; + bool retx_up = false, retx_down = false; #ifndef INCLUDE_DSL_CPE_API_DANUBE fd = open(DSL_CPE_DEVICE_NAME "/0", O_RDWR, 0644); @@ -908,9 +1042,12 @@ static int metrics(struct ubus_context *ctx, struct ubus_object *obj, default: break; }; - line_feature_config(fd, DSL_UPSTREAM); + line_feature_config(fd, DSL_UPSTREAM, &retx_up); + g997_rate_adaptation_status(fd, DSL_UPSTREAM); g997_channel_status(fd, DSL_UPSTREAM); g997_line_status(fd, DSL_UPSTREAM); + if (retx_up) + pm_retx_counters_showtime(fd, DSL_FAR_END); blobmsg_close_table(&b, c); c = blobmsg_open_table(&b, "downstream"); @@ -925,20 +1062,40 @@ static int metrics(struct ubus_context *ctx, struct ubus_object *obj, default: break; }; - line_feature_config(fd, DSL_DOWNSTREAM); + line_feature_config(fd, DSL_DOWNSTREAM, &retx_down); + g997_rate_adaptation_status(fd, DSL_DOWNSTREAM); g997_channel_status(fd, DSL_DOWNSTREAM); g997_line_status(fd, DSL_DOWNSTREAM); + if (retx_down) + pm_retx_counters_showtime(fd, DSL_NEAR_END); + blobmsg_close_table(&b, c); + +#ifndef INCLUDE_DSL_CPE_API_DANUBE + c = blobmsg_open_table(&b, "olr"); + c2 = blobmsg_open_table(&b, "downstream"); + olr_statistics(fd, DSL_DOWNSTREAM); + blobmsg_close_table(&b, c2); + c2 = blobmsg_open_table(&b, "upstream"); + olr_statistics(fd, DSL_UPSTREAM); + blobmsg_close_table(&b, c2); blobmsg_close_table(&b, c); +#endif c = blobmsg_open_table(&b, "errors"); c2 = blobmsg_open_table(&b, "near"); pm_line_sec_counters_total(fd, DSL_NEAR_END); + if (retx_down) + pm_retx_counters_total(fd, DSL_NEAR_END); + pm_channel_counters_total(fd, DSL_NEAR_END); pm_data_path_counters_total(fd, DSL_NEAR_END); retx_statistics(fd, DSL_NEAR_END); blobmsg_close_table(&b, c2); c2 = blobmsg_open_table(&b, "far"); pm_line_sec_counters_total(fd, DSL_FAR_END); + if (retx_up) + pm_retx_counters_total(fd, DSL_FAR_END); + pm_channel_counters_total(fd, DSL_FAR_END); pm_data_path_counters_total(fd, DSL_FAR_END); retx_statistics(fd, DSL_FAR_END); blobmsg_close_table(&b, c2);