[PATCH] ltq-vdsl/ltq-adsl: fix elapsed time calculation

2022-04-25 Thread Jan Hoffmann
The driver maintains elapsed times by repeatedly accumulating the time
since the previous update in a loop. For the elapsed showtime time, the
time difference is truncated to seconds before adding it, leading to a
sizable error over time.

Move the truncation to before calculation of the time difference in
order to remove this error. Also maintain the total elapsed time in the
same way in full seconds, to prevent the unsigned 32-bit counter from
wrapping around after about 50 days.

Testing on a VR9 device shows that the reported line uptime now matches
the actual elapsed wall time. The ADSL variant is only compile-tested,
but it should also work as the relevant code is identical.

Signed-off-by: Jan Hoffmann 
---
 package/kernel/lantiq/ltq-adsl/Makefile   |   2 +-
 .../patches/200-fix-elapsed-time.patch| 122 ++
 package/kernel/lantiq/ltq-vdsl/Makefile   |   2 +-
 .../patches/200-fix-elapsed-time.patch| 122 ++
 4 files changed, 246 insertions(+), 2 deletions(-)
 create mode 100644 
package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch
 create mode 100644 
package/kernel/lantiq/ltq-vdsl/patches/200-fix-elapsed-time.patch

diff --git a/package/kernel/lantiq/ltq-adsl/Makefile 
b/package/kernel/lantiq/ltq-adsl/Makefile
index 31874acaca4e..ac9667493386 100644
--- a/package/kernel/lantiq/ltq-adsl/Makefile
+++ b/package/kernel/lantiq/ltq-adsl/Makefile
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=ltq-adsl
 PKG_VERSION:=3.24.4.4
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 PKG_SOURCE:=drv_dsl_cpe_api_danube-$(PKG_VERSION).tar.gz
 
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/ltq-dsl-$(BUILD_VARIANT)/drv_dsl_cpe_api-$(PKG_VERSION)
 PKG_SOURCE_URL:=@OPENWRT
diff --git a/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch 
b/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch
new file mode 100644
index ..42ec21437155
--- /dev/null
+++ b/package/kernel/lantiq/ltq-adsl/patches/200-fix-elapsed-time.patch
@@ -0,0 +1,122 @@
+--- a/src/include/drv_dsl_cpe_pm_core.h
 b/src/include/drv_dsl_cpe_pm_core.h
+@@ -1525,9 +1525,9 @@ typedef struct
+DSL_boolean_t bShowtimeProcessingStart;
+/** Showtime reached flag*/
+DSL_boolean_t bShowtimeInvTrigger;
+-   /** Current Showtime synchronization time to be used, (msec) */
++   /** Current Showtime synchronization time to be used, (sec) */
+DSL_uint32_t nCurrShowtimeTime;
+-   /** Showtime synchronization time to be used, (msec) */
++   /** Showtime synchronization time to be used, (sec) */
+DSL_uint32_t nElapsedShowtimeTime;
+/** Actual Line state*/
+DSL_LineStateValue_t nLineState;
+--- a/src/pm/drv_dsl_cpe_api_pm.c
 b/src/pm/drv_dsl_cpe_api_pm.c
+@@ -1445,7 +1445,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersTo
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC;
++   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime;
+ 
+pChCounters = 
DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection);
+ 
+@@ -1501,7 +1501,7 @@ DSL_Error_t DSL_DRV_PM_ChannelCountersEx
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC;
++   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime;
+ 
+pChCounters = 
DSL_DRV_PM_PTR_CHANNEL_COUNTERS_TOTAL_EXT(pCounters->nChannel);
+ 
+@@ -2418,7 +2418,7 @@ DSL_Error_t DSL_DRV_PM_DataPathCountersT
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC;
++   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime;
+ 
+pDpCounters = 
DSL_DRV_PM_PTR_DATAPATH_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection);
+ 
+@@ -3190,7 +3190,7 @@ DSL_Error_t DSL_DRV_PM_DataPathFailureCo
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC;
++   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime;
+ 
+pDpCounters = 
DSL_DRV_PM_PTR_DATAPATH_FAILURE_COUNTERS_TOTAL(pCounters->nChannel,pCounters->nDirection);
+ 
+@@ -3950,7 +3950,7 @@ DSL_Error_t DSL_DRV_PM_LineSecCountersTo
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime/DSL_PM_MSEC;
++   pCounters->total.nElapsedTime = 
DSL_DRV_PM_CONTEXT(pContext)->nPmTotalElapsedTime;
+ 
+pLineCounters = 
DSL_DRV_PM_PTR_LINE_SEC_COUNTERS_TOTAL(pCounters->nDirection);
+ 
+@@ -4602,7 +4602,7 @@ DSL_Error_t DSL_DRV_PM_LineInitCountersT
+}
+ 
+/* Fill Total Counters elapsed time*/
+-   pCounters->total.nElapsedTime = 

[PATCH] ltq-atm/ltq-ptm: avoid unnecessary build dependencies

2022-04-25 Thread Jan Hoffmann
Right now, both ltq-adsl-mei and ltq-vdsl-mei are always built, even
when they aren't necessary for the selected variant. This can cause the
build to fail, for example ltq-vdsl-mei doesn't build successfully here
on xway target due to the vectoring callback.

Make these dependencies conditional on the specific package variants,
so they are only built when actually needed.

Signed-off-by: Jan Hoffmann 
---
 package/kernel/lantiq/ltq-atm/Makefile | 13 +
 package/kernel/lantiq/ltq-ptm/Makefile |  4 ++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/package/kernel/lantiq/ltq-atm/Makefile 
b/package/kernel/lantiq/ltq-atm/Makefile
index f675269ca335..b81f3bb29382 100644
--- a/package/kernel/lantiq/ltq-atm/Makefile
+++ b/package/kernel/lantiq/ltq-atm/Makefile
@@ -22,13 +22,18 @@ define KernelPackage/ltq-atm-template
   URL:=http://www.lantiq.com/
   VARIANT:=$(1)
   DEPENDS:=@$(2) +kmod-atm +br2684ctl
+ifeq ($(1),vr9)
+  DEPENDS+= +PACKAGE_kmod-ltq-atm-$(1):kmod-ltq-vdsl-vr9-mei
+else
+  DEPENDS+= +PACKAGE_kmod-ltq-atm-$(1):kmod-ltq-adsl-$(1)-mei
+endif
   FILES:=$(PKG_BUILD_DIR)/ltq_atm_$(1).ko
 endef
 
-KernelPackage/ltq-atm-danube=$(call 
KernelPackage/ltq-atm-template,danube,(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy)
 +kmod-ltq-adsl-danube-mei)
-KernelPackage/ltq-atm-ar9=$(call 
KernelPackage/ltq-atm-template,ar9,TARGET_lantiq_xway +kmod-ltq-adsl-ar9-mei)
-KernelPackage/ltq-atm-ase=$(call 
KernelPackage/ltq-atm-template,ase,TARGET_lantiq_ase +kmod-ltq-adsl-ase-mei)
-KernelPackage/ltq-atm-vr9=$(call 
KernelPackage/ltq-atm-template,vr9,TARGET_lantiq_xrx200 +kmod-ltq-vdsl-vr9-mei)
+KernelPackage/ltq-atm-danube=$(call 
KernelPackage/ltq-atm-template,danube,(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy))
+KernelPackage/ltq-atm-ar9=$(call 
KernelPackage/ltq-atm-template,ar9,TARGET_lantiq_xway)
+KernelPackage/ltq-atm-ase=$(call 
KernelPackage/ltq-atm-template,ase,TARGET_lantiq_ase)
+KernelPackage/ltq-atm-vr9=$(call 
KernelPackage/ltq-atm-template,vr9,TARGET_lantiq_xrx200)
 
 define Build/Configure
 endef
diff --git a/package/kernel/lantiq/ltq-ptm/Makefile 
b/package/kernel/lantiq/ltq-ptm/Makefile
index 33a23d6853fc..b726cb1560d3 100644
--- a/package/kernel/lantiq/ltq-ptm/Makefile
+++ b/package/kernel/lantiq/ltq-ptm/Makefile
@@ -24,9 +24,9 @@ define KernelPackage/ltq-ptm-template
   VARIANT:=$(1)
   DEPENDS:=@TARGET_lantiq_$(2)
 ifeq ($(1),vr9)
-  DEPENDS+= +kmod-ltq-vdsl-vr9-mei
+  DEPENDS+= +PACKAGE_kmod-ltq-ptm-$(1):kmod-ltq-vdsl-vr9-mei
 else
-  DEPENDS+= +kmod-ltq-adsl-$(1)-mei
+  DEPENDS+= +PACKAGE_kmod-ltq-ptm-$(1):kmod-ltq-adsl-$(1)-mei
 endif
 ifeq ($(1),ase)
   DEPENDS+=@BROKEN
-- 
2.35.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [PATCH] realtek: Trap all frames with switch as destination to CPU-port

2022-04-25 Thread Sander Vanheule
Hi Birger,

On Sun, 2022-04-24 at 20:37 +0200, Birger Koblitz wrote:
> This fixes a bug where frames sent to the switch itself were
> flooded to all ports unless the MAC address of the CPU-port
> was learned otherwise.
> 
> Tested-by: Wenli Looi 
> Tested-by: Bjørn Mork 
> Signed-off-by: Birger Koblitz 
> ---
> This was previously sent as a patch with a wrong subject
> "[PATCH] realtek: do not reset SerDes on link change"
> 
>  .../linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c  | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> index 4780632983..858b692640 100644
> --- a/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> +++ b/target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c
> @@ -205,6 +205,12 @@ static int rtl83xx_setup(struct dsa_switch *ds)
> 
> priv->r->l2_learning_setup();
> 
> +   // Make sure all frames sent to the switch's MAC are trapped to the 
> CPU-port
> +   if (priv->family_id == RTL8380_FAMILY_ID)
> +   sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: 
> DROP, 2:
> TRAP2CPU
> +   else
> +   sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);
> +
> /* Enable MAC Polling PHY again */
> rtl83xx_enable_phy_polling(priv);
> pr_debug("Please wait until PHY is settled\n");

checkpatch.pl has some complaints:

WARNING: suspect code indent for conditional statements (8, 12)
#142: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:209:
+   if (priv->family_id == RTL8380_FAMILY_ID)
+   sw_w32(0x2, RTL838X_SPCL_TRAP_SWITCH_MAC_CTRL);  // 0: FWD, 1: 
DROP, 2: TRAP2CPU

WARNING: suspect code indent for conditional statements (8, 12)
#144: FILE: target/linux/realtek/files-5.10/drivers/net/dsa/rtl83xx/dsa.c:211:
+   else
+   sw_w32(0x2, RTL839X_SPCL_TRAP_SWITCH_MAC_CTRL);

WARNING: Missing Signed-off-by: line by nominal patch author 'Birger Koblitz 
'

total: 0 errors, 3 warnings, 12 lines checked


Please indent with tabs, but you can ignore the third warning.


Best,
Sander


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel