From patchwork Tue Apr 13 09:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 1465674 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1:d65d:64ff:fe57:4e05; helo=desiato.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=loyfBaEI; dkim-atps=neutral Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FKL5f4YyVz9sSC for ; Tue, 13 Apr 2021 19:33:58 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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=ZRlPFNiAjNZglJN62CDiiVIT3KIz/TYwV4Q8zVHDSSk=; b=loyfBaEIN3IdDpSPqrF83z44HT GRb4aI/s9QhjHQFEaOickXfe9Bwd/a/9MqWdzJj6JS0pMQ+krN8zg3XIISm9uY5YeyHuE1Sis4ltv N50lxYKWtDakj0ym2wpCTp0SPkncSYfsXomX3Owpjgou6VmmUJtjxaJoNTUln44rMx2JMKdQKfEW2 Dy9uV2nIQgSTO2yFdfthqP49wFfpvKIVB7m3xTuziquQIcFQOmmm10flTOgPwyl6OhApWzKHcJqRx fyHcIg5XcDR4+TwtM9lehGMKbfKBoEPa10E9Kp0xcIBx1KobcK8WJ+O1uivM3/JzT2m9TKwAE8hT6 igQGfsxw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lWFNq-008iUD-LQ; Tue, 13 Apr 2021 09:30:59 +0000 Received: from mxout70.expurgate.net ([91.198.224.70]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lWFNd-008iSm-8y for openwrt-devel@lists.openwrt.org; Tue, 13 Apr 2021 09:30:53 +0000 Received: from [127.0.0.1] (helo=localhost) by relay.expurgate.net with smtp (Exim 4.92) (envelope-from ) id 1lWFNb-0001pR-MA; Tue, 13 Apr 2021 11:30:43 +0200 Received: from [195.243.126.94] (helo=securemail.tdt.de) by relay.expurgate.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lWFNb-000Nyh-1O; Tue, 13 Apr 2021 11:30:43 +0200 Received: from securemail.tdt.de (localhost [127.0.0.1]) by securemail.tdt.de (Postfix) with ESMTP id 5CBC3240041; Tue, 13 Apr 2021 11:30:42 +0200 (CEST) Received: from mail.dev.tdt.de (unknown [10.2.4.42]) by securemail.tdt.de (Postfix) with ESMTP id EEE30240040; Tue, 13 Apr 2021 11:30:41 +0200 (CEST) Received: from feckert.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 454AF2011D; Tue, 13 Apr 2021 11:30:41 +0200 (CEST) From: Florian Eckert To: Eckert.Florian@googlemail.com, a.heider@gmail.com, dev@kresin.me Cc: openwrt-devel@lists.openwrt.org Subject: [PATCH v6 1/1] ltq-vdsl-app: extent dsl metrics with state_num and power_state_num Date: Tue, 13 Apr 2021 11:30:33 +0200 Message-ID: <20210413093033.19757-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.dev.tdt.de X-purgate: clean X-purgate-ID: 151534::1618306243-0001DC19-5F226906/0/0 X-purgate-type: clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210413_103049_386371_E771E9DA X-CRM114-Status: GOOD ( 14.16 ) X-Spam-Score: -0.7 (/) X-Spam-Report: Spam detection software, running on the system "desiato.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: 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 adds the missing information. For this the internal values are mapped to numbers. Content analysis details: (-0.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [91.198.224.70 listed in list.dnswl.org] 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 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 adds the missing information. For this the internal values are mapped to numbers. * additional JSON output for state_num: "state_num": Since not all values are meaningful only the following values are implemented, this can be extended if the future. * LSTATE_MAP_NOT_INITIALIZED * LSTATE_MAP_EXCEPTION * LSTATE_MAP_IDLE * LSTATE_MAP_SILENT * LSTATE_MAP_HANDSHAKE * LSTATE_MAP_FULL_INIT * LSTATE_MAP_SHOWTIME_NO_SYNC * LSTATE_MAP_SHOWTIME_TC_SYNC * LSTATE_MAP_RESYNC * additinal JSON output for power_level: "power_state_num": , Since there are not so many here, all are mapped. * PSTATE_MAP_NA, * PSTATE_MAP_L0, * PSTATE_MAP_L1, * PSTATE_MAP_L2, * PSTATE_MAP_L3, Signed-off-by: Florian Eckert v6: Add state LSTATE_MAP_NOT_INITILIZED at the beginning of the list Start the list LSTATE_MAP with -1 Reviewed-by: Andre Heider --- .../ltq-vdsl-app/src/src/dsl_cpe_ubus.c | 72 +++++++++++++++---- 1 file changed, 58 insertions(+), 14 deletions(-) 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 52b2be20e1..91f36b18a7 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 @@ -34,6 +34,12 @@ str = text; \ break; +#define STR_CASE_MAP(id, text, number) \ + case id: \ + str = text; \ + map = number; \ + break; + #define IOCTL(type, request) \ type out; \ memset(&out, 0, sizeof(type)); \ @@ -99,6 +105,34 @@ typedef enum { PROFILE_35B, } profile_t; +/* These values are exported via ubus and backwards compability + * needs to be kept! + */ +enum { + LSTATE_MAP_UNKNOWN = -1, + LSTATE_MAP_NOT_INITIALIZED, + LSTATE_MAP_EXCEPTION, + LSTATE_MAP_IDLE, + LSTATE_MAP_SILENT, + LSTATE_MAP_HANDSHAKE, + LSTATE_MAP_FULL_INIT, + LSTATE_MAP_SHOWTIME_NO_SYNC, + LSTATE_MAP_SHOWTIME_TC_SYNC, + LSTATE_MAP_RESYNC, +}; + +/* These values are exported via ubus and backwards compability + * needs to be kept! + */ +enum { + PSTATE_MAP_UNKNOWN = -2, + PSTATE_MAP_NA, + PSTATE_MAP_L0, + PSTATE_MAP_L1, + PSTATE_MAP_L2, + PSTATE_MAP_L3, +}; + static DSL_CPE_ThreadCtrl_t thread; static struct ubus_context *ctx; static struct blob_buf b; @@ -306,32 +340,33 @@ static void version_information(int fd) { static void line_state(int fd) { IOCTL(DSL_LineState_t, DSL_FIO_LINE_STATE_GET) + int map = LSTATE_MAP_UNKNOWN; const char *str; switch (out.data.nLineState) { - STR_CASE(DSL_LINESTATE_NOT_INITIALIZED, "Not initialized") - STR_CASE(DSL_LINESTATE_EXCEPTION, "Exception") + STR_CASE_MAP(DSL_LINESTATE_NOT_INITIALIZED, "Not initialized", LSTATE_MAP_NOT_INITIALIZED) + STR_CASE_MAP(DSL_LINESTATE_EXCEPTION, "Exception", LSTATE_MAP_EXCEPTION) STR_CASE(DSL_LINESTATE_NOT_UPDATED, "Not updated") STR_CASE(DSL_LINESTATE_IDLE_REQUEST, "Idle request") - STR_CASE(DSL_LINESTATE_IDLE, "Idle") + STR_CASE_MAP(DSL_LINESTATE_IDLE, "Idle", LSTATE_MAP_IDLE) STR_CASE(DSL_LINESTATE_SILENT_REQUEST, "Silent request") - STR_CASE(DSL_LINESTATE_SILENT, "Silent") - STR_CASE(DSL_LINESTATE_HANDSHAKE, "Handshake") + STR_CASE_MAP(DSL_LINESTATE_SILENT, "Silent", LSTATE_MAP_SILENT) + STR_CASE_MAP(DSL_LINESTATE_HANDSHAKE, "Handshake", LSTATE_MAP_HANDSHAKE) STR_CASE(DSL_LINESTATE_BONDING_CLR, "Bonding CLR") - STR_CASE(DSL_LINESTATE_FULL_INIT, "Full init") + STR_CASE_MAP(DSL_LINESTATE_FULL_INIT, "Full init", LSTATE_MAP_FULL_INIT) STR_CASE(DSL_LINESTATE_SHORT_INIT_ENTRY, "Short init entry") STR_CASE(DSL_LINESTATE_DISCOVERY, "Discovery") STR_CASE(DSL_LINESTATE_TRAINING, "Training") STR_CASE(DSL_LINESTATE_ANALYSIS, "Analysis") STR_CASE(DSL_LINESTATE_EXCHANGE, "Exchange") - STR_CASE(DSL_LINESTATE_SHOWTIME_NO_SYNC, "Showtime without TC-Layer sync") - STR_CASE(DSL_LINESTATE_SHOWTIME_TC_SYNC, "Showtime with TC-Layer sync") + STR_CASE_MAP(DSL_LINESTATE_SHOWTIME_NO_SYNC, "Showtime without TC-Layer sync", LSTATE_MAP_SHOWTIME_NO_SYNC) + STR_CASE_MAP(DSL_LINESTATE_SHOWTIME_TC_SYNC, "Showtime with TC-Layer sync", LSTATE_MAP_SHOWTIME_TC_SYNC) STR_CASE(DSL_LINESTATE_FASTRETRAIN, "Fastretrain") STR_CASE(DSL_LINESTATE_LOWPOWER_L2, "Lowpower L2") STR_CASE(DSL_LINESTATE_LOOPDIAGNOSTIC_ACTIVE, "Loopdiagnostic active") STR_CASE(DSL_LINESTATE_LOOPDIAGNOSTIC_DATA_EXCHANGE, "Loopdiagnostic data exchange") STR_CASE(DSL_LINESTATE_LOOPDIAGNOSTIC_DATA_REQUEST, "Loopdiagnostic data request") STR_CASE(DSL_LINESTATE_LOOPDIAGNOSTIC_COMPLETE, "Loopdiagnostic complete") - STR_CASE(DSL_LINESTATE_RESYNC, "Resync") + STR_CASE_MAP(DSL_LINESTATE_RESYNC, "Resync", LSTATE_MAP_RESYNC) STR_CASE(DSL_LINESTATE_TEST, "Test") STR_CASE(DSL_LINESTATE_TEST_LOOP, "Test loop") STR_CASE(DSL_LINESTATE_TEST_REVERB, "Test reverb") @@ -351,9 +386,13 @@ static void line_state(int fd) { str = NULL; break; }; + if (str) m_str("state", str); + if (map != LSTATE_MAP_UNKNOWN ) + m_u32("state_num", map); + m_bool("up", out.data.nLineState == DSL_LINESTATE_SHOWTIME_TC_SYNC); } @@ -377,19 +416,24 @@ 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) + int map = PSTATE_MAP_UNKNOWN; const char *str; switch (out.data.nPowerManagementStatus) { - STR_CASE(DSL_G997_PMS_NA, "Power management state is not available") - STR_CASE(DSL_G997_PMS_L0, "L0 - Synchronized") - STR_CASE(DSL_G997_PMS_L1, "L1 - Power Down Data transmission (G.992.2)") - STR_CASE(DSL_G997_PMS_L2, "L2 - Power Down Data transmission (G.992.3 and G.992.4)") - STR_CASE(DSL_G997_PMS_L3, "L3 - No power") + STR_CASE_MAP(DSL_G997_PMS_NA, "Power management state is not available", PSTATE_MAP_NA) + STR_CASE_MAP(DSL_G997_PMS_L0, "L0 - Synchronized", PSTATE_MAP_L0) + STR_CASE_MAP(DSL_G997_PMS_L1, "L1 - Power Down Data transmission (G.992.2)", PSTATE_MAP_L1) + STR_CASE_MAP(DSL_G997_PMS_L2, "L2 - Power Down Data transmission (G.992.3 and G.992.4)", PSTATE_MAP_L2) + STR_CASE_MAP(DSL_G997_PMS_L3, "L3 - No power", PSTATE_MAP_L3) default: str = NULL; break; }; + if (str) m_str("power_state", str); + + if (map != PSTATE_MAP_UNKNOWN) + m_u32("power_state_num", map); } static void g997_xtu_system_enabling(int fd, standard_t *standard) {