[OpenWrt-Devel] [PATCH v3] lantiq: get more status information from xDSL

2015-08-05 Thread feckert
Signed-off-by: Florian Eckert eckert.flor...@googlemail.com
Signed-off-by: Helge Mader hma...@tdt.de
Tested-by: Martin Blumenstingl martin.blumensti...@googlemail.com
Tested-by: Andre Heider a.hei...@gmail.com
---

v2 fix annex and line mode comma
v2 fix latency to ms
v3 fix latency syntax quotation error x ms
v3 fix echo  separation removed from status function

 .../lantiq/base-files/lib/functions/lantiq_dsl.sh  |  412 +++-
 1 file changed, 400 insertions(+), 12 deletions(-)
 mode change 100644 = 100755 
target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh

diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh 
b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
old mode 100644
new mode 100755
index 56b8652..7809d01
--- a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
@@ -19,6 +19,9 @@ dsl_cmd() {
 dsl_val() {
echo $(expr $1 : '.*'$2'=\([-\.[:alnum:]]*\).*')
 }
+dsl_string() {
+   echo $(expr $1 : '.*'$2'=(\([A-Z0-9,]*\))')
+}
 
 #
 # Simple divide by 10 routine to cope with one decimal place
@@ -49,6 +52,16 @@ scale() {
fi
 }
 
+scale_latency() {
+   local val=$1
+   local a
+   local b
+
+   a=$(expr $val / 100)
+   b=$(expr $val % 100)
+   printf %d.%d ms ${a} ${b}
+}
+
 #
 # Read the data rates for both directions
 #
@@ -77,7 +90,7 @@ data_rates() {
echo dsl.data_rate_down_s=\$sdrd\
echo dsl.data_rate_up_s=\$sdru\
else
-   echo Data Rate:${sdrd}/s / ${sdru}/s
+   echo Data Rate:Down: ${sdrd}/s 
/ Up: ${sdru}/s
fi
 }
 
@@ -92,11 +105,340 @@ chipset() {
vig=$(dsl_cmd vig)
cs=$(dsl_val $vig DSL_ChipSetType)
csv=$(dsl_val $vig DSL_ChipSetHWVersion)
+   csfw=$(dsl_val $vig DSL_ChipSetFWVersion)
+   csapi=$(dsl_val $vig DSL_DriverVersionApi)
 
if [ $action = lucistat ]; then
echo dsl.chipset=\${cs} ${csv}\
+   echo dsl.firmware_version=\${csfw}\
+   echo dsl.api_version=\${csapi}\
else
-   echo Chipset:  ${cs} ${csv}
+   echo Chipset:  ${cs} ${csv}
+   echo Firmware Version: ${csfw}
+   echo API Version:  ${csapi}
+   fi
+}
+
+#
+# Vendor information
+#
+vendor() {
+   local lig
+   local vid
+   local svid
+
+   lig=$(dsl_cmd g997lig 1)
+   vid=$(dsl_string $lig G994VendorID)
+   svid=$(dsl_string $lig SystemVendorID)
+
+   if [ $action = lucistat ]; then
+   echo dsl.atuc_vendor_id=\${vid}\
+   echo dsl.atuc_system_vendor_id=\${svid}\
+   else
+   echo ATU-C Vendor ID:  ${vid}
+   echo ATU-C System Vendor ID:   ${svid}
+   fi
+}
+
+#
+# XTSE capabilities
+#
+xtse() {
+   local xtusesg
+   local xtse1
+   local xtse2
+   local xtse3
+   local xtse4
+   local xtse5
+   local xtse6
+   local xtse7
+   local xtse8
+
+   local xtse_s=
+
+   local annex_s=
+   local line_mode_s=
+   local cmd=
+
+   xtusesg=$(dsl_cmd g997xtusesg)
+   xtse1=$(dsl_val $xtusesg XTSE1)
+   xtse2=$(dsl_val $xtusesg XTSE2)
+   xtse3=$(dsl_val $xtusesg XTSE3)
+   xtse4=$(dsl_val $xtusesg XTSE4)
+   xtse5=$(dsl_val $xtusesg XTSE5)
+   xtse6=$(dsl_val $xtusesg XTSE6)
+   xtse7=$(dsl_val $xtusesg XTSE7)
+   xtse8=$(dsl_val $xtusesg XTSE8)
+
+   # Evaluate Annex (according to G.997.1, 7.3.1.1.1)
+   if [ $((xtse1  13)) != 0 \
+   -o $((xtse2  1)) != 0 \
+   -o $((xtse3  12)) != 0 \
+   -o $((xtse4  3)) != 0 \
+   -o $((xtse6  3)) != 0 \
+   -o $((xtse8  1)) != 0 ]; then
+   annex_s= A,
+   fi
+
+   if [ $((xtse1  48)) != 0 \
+   -o $((xtse2  2)) != 0 \
+   -o $((xtse3  48)) != 0 \
+   -o $((xtse6  12)) != 0 \
+   -o $((xtse8  2)) != 0 ]; then
+   annex_s=$annex_s B,
+   fi
+
+   if [ $((xtse1  194)) != 0 \
+   -o $((xtse2  12)) != 0 \
+   -o $((xtse8  4)) != 0 ]; then
+   annex_s=$annex_s C,
+   fi
+
+   if [ $((xtse4  48)) != 0 \
+   -o $((xtse5  3)) != 0 \
+   -o $((xtse6  192)) != 0 ]; then
+   annex_s=$annex_s I,
+   fi
+
+   if [ $((xtse4  192)) != 0 \
+   -o $((xtse7  3)) != 0 ]; then
+   annex_s=$annex_s J,
+   fi
+
+   if [ $((xtse5  60)) != 0 ]; then
+   annex_s=$annex_s L,
+   fi
+
+   if [ $((xtse5  192)) != 0 \
+   -o $((xtse7  12)) != 0 ]; then
+   annex_s=$annex_s M,
+   fi
+
+   annex_s=`echo ${annex_s:1}`
+   annex_s=`echo ${annex_s%?}`
+
+   # Evaluate Line Mode (according to G.997.1, 

[OpenWrt-Devel] [PATCH v2] lantiq: get more status information from xDSL

2015-07-31 Thread feckert
Signed-off-by: Florian Eckert eckert.flor...@googlemail.com
Signed-off-by: Helge Mader hma...@tdt.de
Tested-by: Martin Blumenstingl martin.blumensti...@googlemail.com
---

v2 fix annex and line mode comma
v2 fix latency to ms

 .../lantiq/base-files/lib/functions/lantiq_dsl.sh  |  423 +++-
 1 file changed, 411 insertions(+), 12 deletions(-)
 mode change 100644 = 100755 
target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh

diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh 
b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
old mode 100644
new mode 100755
index 56b8652..938658b
--- a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
@@ -19,6 +19,9 @@ dsl_cmd() {
 dsl_val() {
echo $(expr $1 : '.*'$2'=\([-\.[:alnum:]]*\).*')
 }
+dsl_string() {
+   echo $(expr $1 : '.*'$2'=(\([A-Z0-9,]*\))')
+}
 
 #
 # Simple divide by 10 routine to cope with one decimal place
@@ -49,6 +52,16 @@ scale() {
fi
 }
 
+scale_latency() {
+   local val=$1
+   local a
+   local b
+
+   a=$(expr $val / 100)
+   b=$(expr $val % 100)
+   printf %d.%d ms ${a} ${b}
+}
+
 #
 # Read the data rates for both directions
 #
@@ -77,7 +90,7 @@ data_rates() {
echo dsl.data_rate_down_s=\$sdrd\
echo dsl.data_rate_up_s=\$sdru\
else
-   echo Data Rate:${sdrd}/s / ${sdru}/s
+   echo Data Rate:Down: ${sdrd}/s 
/ Up: ${sdru}/s
fi
 }
 
@@ -92,11 +105,340 @@ chipset() {
vig=$(dsl_cmd vig)
cs=$(dsl_val $vig DSL_ChipSetType)
csv=$(dsl_val $vig DSL_ChipSetHWVersion)
+   csfw=$(dsl_val $vig DSL_ChipSetFWVersion)
+   csapi=$(dsl_val $vig DSL_DriverVersionApi)
 
if [ $action = lucistat ]; then
echo dsl.chipset=\${cs} ${csv}\
+   echo dsl.firmware_version=\${csfw}\
+   echo dsl.api_version=\${csapi}\
else
-   echo Chipset:  ${cs} ${csv}
+   echo Chipset:  ${cs} ${csv}
+   echo Firmware Version: ${csfw}
+   echo API Version:  ${csapi}
+   fi
+}
+
+#
+# Vendor information
+#
+vendor() {
+   local lig
+   local vid
+   local svid
+
+   lig=$(dsl_cmd g997lig 1)
+   vid=$(dsl_string $lig G994VendorID)
+   svid=$(dsl_string $lig SystemVendorID)
+
+   if [ $action = lucistat ]; then
+   echo dsl.atuc_vendor_id=\${vid}\
+   echo dsl.atuc_system_vendor_id=\${svid}\
+   else
+   echo ATU-C Vendor ID:  ${vid}
+   echo ATU-C System Vendor ID:   ${svid}
+   fi
+}
+
+#
+# XTSE capabilities
+#
+xtse() {
+   local xtusesg
+   local xtse1
+   local xtse2
+   local xtse3
+   local xtse4
+   local xtse5
+   local xtse6
+   local xtse7
+   local xtse8
+
+   local xtse_s=
+
+   local annex_s=
+   local line_mode_s=
+   local cmd=
+
+   xtusesg=$(dsl_cmd g997xtusesg)
+   xtse1=$(dsl_val $xtusesg XTSE1)
+   xtse2=$(dsl_val $xtusesg XTSE2)
+   xtse3=$(dsl_val $xtusesg XTSE3)
+   xtse4=$(dsl_val $xtusesg XTSE4)
+   xtse5=$(dsl_val $xtusesg XTSE5)
+   xtse6=$(dsl_val $xtusesg XTSE6)
+   xtse7=$(dsl_val $xtusesg XTSE7)
+   xtse8=$(dsl_val $xtusesg XTSE8)
+
+   # Evaluate Annex (according to G.997.1, 7.3.1.1.1)
+   if [ $((xtse1  13)) != 0 \
+   -o $((xtse2  1)) != 0 \
+   -o $((xtse3  12)) != 0 \
+   -o $((xtse4  3)) != 0 \
+   -o $((xtse6  3)) != 0 \
+   -o $((xtse8  1)) != 0 ]; then
+   annex_s= A,
+   fi
+
+   if [ $((xtse1  48)) != 0 \
+   -o $((xtse2  2)) != 0 \
+   -o $((xtse3  48)) != 0 \
+   -o $((xtse6  12)) != 0 \
+   -o $((xtse8  2)) != 0 ]; then
+   annex_s=$annex_s B,
+   fi
+
+   if [ $((xtse1  194)) != 0 \
+   -o $((xtse2  12)) != 0 \
+   -o $((xtse8  4)) != 0 ]; then
+   annex_s=$annex_s C,
+   fi
+
+   if [ $((xtse4  48)) != 0 \
+   -o $((xtse5  3)) != 0 \
+   -o $((xtse6  192)) != 0 ]; then
+   annex_s=$annex_s I,
+   fi
+
+   if [ $((xtse4  192)) != 0 \
+   -o $((xtse7  3)) != 0 ]; then
+   annex_s=$annex_s J,
+   fi
+
+   if [ $((xtse5  60)) != 0 ]; then
+   annex_s=$annex_s L,
+   fi
+
+   if [ $((xtse5  192)) != 0 \
+   -o $((xtse7  12)) != 0 ]; then
+   annex_s=$annex_s M,
+   fi
+
+   annex_s=`echo ${annex_s:1}`
+   annex_s=`echo ${annex_s%?}`
+
+   # Evaluate Line Mode (according to G.997.1, 7.3.1.1.1)
+
+   # Regional standard: ANSI T1.413
+   if [ $((xtse1  1)) != 0  ]; then
+   line_mode_s= T1.413,
+   fi

[OpenWrt-Devel] [PATCH] lantiq: get more status information from xDSL

2015-07-30 Thread feckert
Signed-off-by: Florian Eckert eckert.flor...@googlemail.com
Signed-off-by: Helge Mader hma...@tdt.de
---
 .../lantiq/base-files/lib/functions/lantiq_dsl.sh  |  400 +++-
 1 file changed, 388 insertions(+), 12 deletions(-)
 mode change 100644 = 100755 
target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh

diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh 
b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
old mode 100644
new mode 100755
index 56b8652..044bffa
--- a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
@@ -19,6 +19,9 @@ dsl_cmd() {
 dsl_val() {
echo $(expr $1 : '.*'$2'=\([-\.[:alnum:]]*\).*')
 }
+dsl_string() {
+   echo $(expr $1 : '.*'$2'=(\([A-Z0-9,]*\))')
+}
 
 #
 # Simple divide by 10 routine to cope with one decimal place
@@ -77,7 +80,7 @@ data_rates() {
echo dsl.data_rate_down_s=\$sdrd\
echo dsl.data_rate_up_s=\$sdru\
else
-   echo Data Rate:${sdrd}/s / ${sdru}/s
+   echo Data Rate:Down: ${sdrd}/s 
/ Up: ${sdru}/s
fi
 }
 
@@ -92,11 +95,327 @@ chipset() {
vig=$(dsl_cmd vig)
cs=$(dsl_val $vig DSL_ChipSetType)
csv=$(dsl_val $vig DSL_ChipSetHWVersion)
+   csfw=$(dsl_val $vig DSL_ChipSetFWVersion)
+   csapi=$(dsl_val $vig DSL_DriverVersionApi)
 
if [ $action = lucistat ]; then
echo dsl.chipset=\${cs} ${csv}\
+   echo dsl.firmware_version=\${csfw}\
+   echo dsl.api_version=\${csapi}\
+   else
+   echo Chipset:  ${cs} ${csv}
+   echo Firmware Version: ${csfw}
+   echo API Version:  ${csapi}
+   fi
+}
+
+#
+# Vendor information
+#
+vendor() {
+   local lig
+   local vid
+   local svid
+
+   lig=$(dsl_cmd g997lig 1)
+   vid=$(dsl_string $lig G994VendorID)
+   svid=$(dsl_string $lig SystemVendorID)
+
+   if [ $action = lucistat ]; then
+   echo dsl.atuc_vendor_id=\${vid}\
+   echo dsl.atuc_system_vendor_id=\${svid}\
+   else
+   echo ATU-C Vendor ID:  ${vid}
+   echo ATU-C System Vendor ID:   ${svid}
+   fi
+}
+
+#
+# XTSE capabilities
+#
+xtse() {
+   local xtusesg
+   local xtse1
+   local xtse2
+   local xtse3
+   local xtse4
+   local xtse5
+   local xtse6
+   local xtse7
+   local xtse8
+
+   local xtse_s=
+
+   local annex_s=
+   local line_mode_s=
+
+   xtusesg=$(dsl_cmd g997xtusesg)
+   xtse1=$(dsl_val $xtusesg XTSE1)
+   xtse2=$(dsl_val $xtusesg XTSE2)
+   xtse3=$(dsl_val $xtusesg XTSE3)
+   xtse4=$(dsl_val $xtusesg XTSE4)
+   xtse5=$(dsl_val $xtusesg XTSE5)
+   xtse6=$(dsl_val $xtusesg XTSE6)
+   xtse7=$(dsl_val $xtusesg XTSE7)
+   xtse8=$(dsl_val $xtusesg XTSE8)
+
+   # Evaluate Annex (according to G.997.1, 7.3.1.1.1)
+   if [ $((xtse1  13)) != 0 \
+   -o $((xtse2  1)) != 0 \
+   -o $((xtse3  12)) != 0 \
+   -o $((xtse4  3)) != 0 \
+   -o $((xtse6  3)) != 0 \
+   -o $((xtse8  1)) != 0 ]; then
+   annex_s= A, 
+   fi
+
+   if [ $((xtse1  48)) != 0 \
+   -o $((xtse2  2)) != 0 \
+   -o $((xtse3  48)) != 0 \
+   -o $((xtse6  12)) != 0 \
+   -o $((xtse8  2)) != 0 ]; then
+   annex_s=$annex_s B, 
+   fi
+
+   if [ $((xtse1  194)) != 0 \
+   -o $((xtse2  12)) != 0 \
+   -o $((xtse8  4)) != 0 ]; then
+   annex_s=$annex_s C, 
+   fi
+
+   if [ $((xtse4  48)) != 0 \
+   -o $((xtse5  3)) != 0 \
+   -o $((xtse6  192)) != 0 ]; then
+   annex_s=$annex_s I, 
+   fi
+
+   if [ $((xtse4  192)) != 0 \
+   -o $((xtse7  3)) != 0 ]; then
+   annex_s=$annex_s J, 
+   fi
+
+   if [ $((xtse5  60)) != 0 ]; then
+   annex_s=$annex_s L, 
+   fi
+
+   if [ $((xtse5  192)) != 0 \
+   -o $((xtse7  12)) != 0 ]; then
+   annex_s=$annex_s M,
+   fi
+
+
+   # Evaluate Line Mode (according to G.997.1, 7.3.1.1.1)
+
+   # Regional standard: ANSI T1.413
+   if [ $((xtse1  1)) != 0  ]; then
+   line_mode_s= T1.413, 
+   fi
+
+   # Regional standard: TS 101 388
+   if [ $((xtse1  1)) != 0  ]; then
+   line_mode_s=$line_mode_s TS 101 388, 
+   fi
+
+   if [ $((xtse1  252)) != 0  ]; then
+   line_mode_s=$line_mode_s G.992.1 (ADSL), 
+   fi
+
+   if [ $((xtse2  15)) != 0  ]; then
+   line_mode_s=$line_mode_s G.992.2 (ADSL lite), 
+   fi
+
+   if [ $((xtse3  60)) != 0 \
+   -o $((xtse4  240)) != 0 \
+   -o $((xtse5  252)) != 0  ]; then
+