Re: [OpenWrt-Devel] [PATCH 2/3] [rpcd] file: handle return output of b64_decode

2016-04-11 Thread Jo-Philipp Wich
Hi Luka,

Please use ssize_t instead.

Regards,
Jo

> Am 11.04.2016 um 18:56 schrieb Luka Perkov :
> 
> Solve this compile warning:
> 
> file.c:300:16: error: comparison of unsigned expression < 0 is always false 
> [-Werror,-Wtautological-compare]
>if (data_len < 0)
> 
> Signed-off-by: Luka Perkov 
> ---
> file.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/file.c b/file.c
> index 91a55a1..6ddde32 100644
> --- a/file.c
> +++ b/file.c
> @@ -271,7 +271,7 @@ rpc_file_write(struct ubus_context *ctx, struct 
> ubus_object *obj,
>mode_t prev_mode, mode = 0666;
>int fd, rv = 0;
>void *data = NULL;
> -size_t data_len = 0;
> +int data_len = 0;
> 
>blobmsg_parse(rpc_file_rw_policy, __RPC_F_RW_MAX, tb,
>  blob_data(msg), blob_len(msg));
> -- 
> 2.8.0
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ar71xx: Add TP-Link TL-WR740N v6 support to 15.05.1

2016-04-11 Thread Stijn Segers
This patch adds support for the TP-Link TL-WR740N v6 to OpenWrt Chaos Calmer. 
Hardware wise, it's very similar to the TL-WR841N v10. See the forum thread 
[1]. Credit goes to the user 'traveler' who did the legwork and tested builds.

Also thanks to Matthias Schiffer for clarifying the DEVICE_PROFILE settings.

Signed-off by: Stijn Segers 

[1]: https://forum.openwrt.org/viewtopic.php?pid=318704

---
 target/linux/ar71xx/image/Makefile | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/image/Makefile 
b/target/linux/ar71xx/image/Makefile
index 80adedb..f533805 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -509,6 +509,13 @@ define Device/tl-wr740n-v5
 CONSOLE := ttyATH0,115200
 endef
 
+define Device/tl-wr740n-v6
+$(Device/tplink-4mlzma)
+BOARDNAME := TL-WR841N-v9
+DEVICE_PROFILE := TLWR740
+TPLINK_HWID := 0x0746
+endef
+
 define Device/tl-wr741nd-v1
 $(Device/tplink-4m)
 BOARDNAME := TL-WR741ND
@@ -546,7 +553,7 @@ define Device/tl-wr743nd-v2
 TPLINK_HWID := 0x07430002
 CONSOLE := ttyATH0,115200
 endef
-TARGET_DEVICES += tl-wr740n-v4 tl-wr740n-v5 tl-wr741nd-v1 tl-wr741nd-v2 
tl-wr741nd-v4 tl-wr741nd-v5 tl-wr743nd-v2
+TARGET_DEVICES += tl-wr740n-v4 tl-wr740n-v5 tl-wr740n-v6 tl-wr741nd-v1 
tl-wr741nd-v2 tl-wr741nd-v4 tl-wr741nd-v5 tl-wr743nd-v2
 
 define Device/tl-wr841-v8
 $(Device/tplink-4mlzma)
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ar71xx: Add TP-Link TL-WR740N v6 support to trunk

2016-04-11 Thread Stijn Segers
This patch adds support for the TP-Link TL-WR740N v6 into OpenWrt trunk. 
Hardware wise, it's very similar to the TL-WR841N v10. See the forum thread 
[1]. Credit goes to the user 'traveler' who did the legwork and tested builds.

Also thanks to Matthias Schiffer for clarifying the DEVICE_PROFILE settings.

Signed-off by: Stijn Segers 

[1]: https://forum.openwrt.org/viewtopic.php?pid=318704

---
 target/linux/ar71xx/image/Makefile | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/image/Makefile 
b/target/linux/ar71xx/image/Makefile
index e4e2fcf..c10d8f1 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -753,6 +753,13 @@ define Device/tl-wr740n-v5
 CONSOLE := ttyATH0,115200
 endef
 
+define Device/tl-wr740n-v6
+$(Device/tplink-4mlzma)
+BOARDNAME := TL-WR841N-v9
+DEVICE_PROFILE := TLWR740
+TPLINK_HWID := 0x0746
+endef
+
 define Device/tl-wr741nd-v1
 $(Device/tplink-4m)
 BOARDNAME := TL-WR741ND
@@ -797,7 +804,7 @@ define Device/tl-wr743nd-v2
 TPLINK_HWID := 0x07430002
 CONSOLE := ttyATH0,115200
 endef
-TARGET_DEVICES += tl-wr740n-v1 tl-wr740n-v3 tl-wr740n-v4 tl-wr740n-v5 
tl-wr741nd-v1 tl-wr741nd-v2 tl-wr741nd-v4 tl-wr741nd-v5 tl-wr743nd-v1 
tl-wr743nd-v2
+TARGET_DEVICES += tl-wr740n-v1 tl-wr740n-v3 tl-wr740n-v4 tl-wr740n-v5 
tl-wr740n-v6 tl-wr741nd-v1 tl-wr741nd-v2 tl-wr741nd-v4 tl-wr741nd-v5 
tl-wr743nd-v1 tl-wr743nd-v2
 
 define Device/tl-wr841-v1.5
 $(Device/tplink-4m)
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ar71xx: Add support for the OMYlink OMY-X1

2016-04-11 Thread L. D. Pinney
https://wiki.openwrt.org/toh/omylink/omy-g1

http://www.omylink.com/

Signed-off-by: L. D. Pinney 

---

 target/linux/ar71xx/base-files/etc/board.d/01_leds|   5 +++
 target/linux/ar71xx/base-files/etc/board.d/02_network |   1 +
 target/linux/ar71xx/base-files/etc/diag.sh|   3 ++
 target/linux/ar71xx/base-files/lib/ar71xx.sh  |   3 ++
 target/linux/ar71xx/base-files/lib/upgrade/platform.sh|   1 +
 target/linux/ar71xx/config-4.1|   1 +
 target/linux/ar71xx/config-4.4|   1 +
 target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt |  10 ++
 target/linux/ar71xx/files/arch/mips/ath79/Makefile|   1 +
 target/linux/ar71xx/files/arch/mips/ath79/mach-omy-g1.c   | 123 
++
 target/linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/generic/profiles/omy.mk   |  10 ++
 target/linux/ar71xx/image/Makefile|   9 -
 tools/firmware-utils/src/mktplinkfw.c |   1 +
 14 files changed, 169 insertions(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index b2469bf..4546107 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -398,6 +398,11 @@ om5p-ac)
ucidef_set_led_netdev "port1" "port1" "om5pac:blue:lan" "eth0"
ucidef_set_led_netdev "port2" "port2" "om5pac:blue:wan" "eth1"
;;
+omy-g1)
+   ucidef_set_led_wlan "wlan" "WLAN" "omy:green:wlan" "phy0tpt"
+   ucidef_set_led_netdev "wan" "WAN" "omy:green:wan" "eth0"
+   ucidef_set_led_netdev "lan" "LAN" "omy:green:lan" "eth1"
+   ;;
 
 omy-x1)
ucidef_set_led_default "power" "POWER" "omy:green:power" "1"
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
b/target/linux/ar71xx/base-files/etc/board.d/02_network
index 8fdfa07..7724a08 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -220,6 +220,7 @@ tl-wr941nd)
;;
 
 dir-615-i1 |\
+omy-g1 |\
 r6100 |\
 smart-300 |\
 tl-mr3420-v2 |\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index 1f9bd3f..77fa398 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -218,6 +218,9 @@ get_status_led() {
om5p-acv2)
status_led="om5pac:blue:power"
;;
+   omy-g1)
+   status_led="omy:green:wlan"
+   ;;
omy-x1)
status_led="omy:green:power"
;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 3d4541e..0c9dddc 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -123,6 +123,9 @@ tplink_board_detect() {
"007260"*)
model="TellStick ZNet Lite"
;;
+   "066601"*)
+   model="OMYlink OMY-G1"
+   ;;
"066602"*)
model="OMYlink OMY-X1"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index d44ece5..5334600 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -340,6 +340,7 @@ platform_check_image() {
gl-inet | \
mc-mac1200r | \
minibox-v1 |\
+   omy-g1 |\
omy-x1 |\
onion-omega | \
oolite | \
diff --git a/target/linux/ar71xx/config-4.1 b/target/linux/ar71xx/config-4.1
index fa98643..40cf453 100644
--- a/target/linux/ar71xx/config-4.1
+++ b/target/linux/ar71xx/config-4.1
@@ -111,6 +111,7 @@ CONFIG_ATH79_MACH_OM2P=y
 CONFIG_ATH79_MACH_OM5P=y
 CONFIG_ATH79_MACH_OM5P_AC=y
 CONFIG_ATH79_MACH_OM5P_ACv2=y
+CONFIG_ATH79_MACH_OMY_G1=y
 CONFIG_ATH79_MACH_OMY_X1=y
 CONFIG_ATH79_MACH_ONION_OMEGA=y
 CONFIG_ATH79_MACH_PB42=y
diff --git a/target/linux/ar71xx/config-4.4 b/target/linux/ar71xx/config-4.4
index ec04c28..860b1e1 100644
--- a/target/linux/ar71xx/config-4.4
+++ b/target/linux/ar71xx/config-4.4
@@ -114,6 +114,7 @@ CONFIG_ATH79_MACH_OM2P=y
 CONFIG_ATH79_MACH_OM5P=y
 CONFIG_ATH79_MACH_OM5P_AC=y
 CONFIG_ATH79_MACH_OM5P_ACv2=y
+CONFIG_ATH79_MACH_OMY_G1=y
 CONFIG_ATH79_MACH_OMY_X1=y
 CONFIG_ATH79_MACH_ONION_OMEGA=y
 CONFIG_ATH79_MACH_PB42=y
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index 8c77645..e6879a9 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -890,6 +890,16 @@ config ATH79_MACH_OM5P_AC

[OpenWrt-Devel] [PATCH] ipq806x: enable hard float

2016-04-11 Thread Adrian Panella


Sorry, resubmitting again fixing format problem.

commit e40d7bf480243f855ad38e7752b96ba1e744ea1c
Author: Adrian Panella 
Date:   Tue Apr 5 21:45:14 2016 -0500

IPQ806X: enable hard float

Signed-off-by: Adrian Panella 

diff --git a/target/linux/ipq806x/Makefile b/target/linux/ipq806x/Makefile
index 97a40cf..689ba64 100644
--- a/target/linux/ipq806x/Makefile
+++ b/target/linux/ipq806x/Makefile
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
 ARCH:=arm
 BOARD:=ipq806x
 BOARDNAME:=Qualcomm Atheros IPQ806X
-FEATURES:=squashfs nand ubifs
+FEATURES:=squashfs nand ubifs fpu
 CPU_TYPE:=cortex-a9
 CPU_SUBTYPE:=neon-vfpv4
 MAINTAINER:=John Crispin 
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ipq806x: enable hard float

2016-04-11 Thread Adrian Panella

resubmitting fixing format problem

commit e40d7bf480243f855ad38e7752b96ba1e744ea1c

Author: Adrian Panella 

Date: Tue Apr 5 21:45:14 2016 -0500

IPQ806X: enable hard float

Signed-off-by: Adrian Panella 

diff --git a/target/linux/ipq806x/Makefile b/target/linux/ipq806x/Makefile

index 97a40cf..689ba64 100644

--- a/target/linux/ipq806x/Makefile

+++ b/target/linux/ipq806x/Makefile

@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk

ARCH:=arm

BOARD:=ipq806x

BOARDNAME:=Qualcomm Atheros IPQ806X

-FEATURES:=squashfs nand ubifs

+FEATURES:=squashfs nand ubifs fpu

CPU_TYPE:=cortex-a9

CPU_SUBTYPE:=neon-vfpv4

MAINTAINER:=John Crispin 

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


Re: [OpenWrt-Devel] rsync mirror of download.openwrt.org ?

2016-04-11 Thread Daniel Petre

On 04/12/2016 12:54 AM, Laurent GUERBY wrote:

On Fri, 2016-03-25 at 19:02 +0100, Laurent GUERBY wrote:

On Sat, 2016-03-19 at 15:47 +0100, John Crispin wrote:


On 19/03/2016 14:10, Laurent GUERBY wrote:

Hi,

We've setup a mirror of openwrt on a 10G+ connection IPv4+v6, MPTCP
support using initial rsync from ba.mirror.garr.it :

http://openwrt.tetaneutral.net

But garr.it does not have 15.05.1, is there a way to directly rsync from
downloads.openwrt.org ? Or any other way ? (push would be okay if
needed).

Sincerely

Laurent GUERBY
AS197422 http://tetaneutral.net


i can rsync 15.05.1 to your server if that is ok for you ...


Ok for us :)


What's the space requirement for the whole Chaos Calmer release please? 
I'm interested in setting a mirror too..




Laurent

PS: public key request sent last sunday by mail
(may be lost somewhere ?)


Ping ?

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


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


Re: [OpenWrt-Devel] rsync mirror of download.openwrt.org ?

2016-04-11 Thread Laurent GUERBY
On Fri, 2016-03-25 at 19:02 +0100, Laurent GUERBY wrote:
> On Sat, 2016-03-19 at 15:47 +0100, John Crispin wrote:
> > 
> > On 19/03/2016 14:10, Laurent GUERBY wrote:
> > > Hi, 
> > > 
> > > We've setup a mirror of openwrt on a 10G+ connection IPv4+v6, MPTCP
> > > support using initial rsync from ba.mirror.garr.it :
> > > 
> > > http://openwrt.tetaneutral.net
> > > 
> > > But garr.it does not have 15.05.1, is there a way to directly rsync from
> > > downloads.openwrt.org ? Or any other way ? (push would be okay if
> > > needed).
> > > 
> > > Sincerely
> > > 
> > > Laurent GUERBY
> > > AS197422 http://tetaneutral.net
> > 
> > i can rsync 15.05.1 to your server if that is ok for you ...
> 
> Ok for us :)
> 
> Laurent
> 
> PS: public key request sent last sunday by mail
> (may be lost somewhere ?)

Ping ?

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


[OpenWrt-Devel] [PATCH 2/3] [rpcd] file: handle return output of b64_decode

2016-04-11 Thread Luka Perkov
Solve this compile warning:

file.c:300:16: error: comparison of unsigned expression < 0 is always false 
[-Werror,-Wtautological-compare]
if (data_len < 0)

Signed-off-by: Luka Perkov 
---
 file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/file.c b/file.c
index 91a55a1..6ddde32 100644
--- a/file.c
+++ b/file.c
@@ -271,7 +271,7 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object 
*obj,
mode_t prev_mode, mode = 0666;
int fd, rv = 0;
void *data = NULL;
-   size_t data_len = 0;
+   int data_len = 0;
 
blobmsg_parse(rpc_file_rw_policy, __RPC_F_RW_MAX, tb,
  blob_data(msg), blob_len(msg));
-- 
2.8.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 3/3] [rpcd] file: add myself in Copyright header

2016-04-11 Thread Luka Perkov
Signed-off-by: Luka Perkov 
---
 file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/file.c b/file.c
index 6ddde32..1c4d8bc 100644
--- a/file.c
+++ b/file.c
@@ -2,6 +2,7 @@
  * rpcd - UBUS RPC server
  *
  *   Copyright (C) 2013-2014 Jo-Philipp Wich 
+ *   Copyright (C) 2016 Luka Perkov 
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
-- 
2.8.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/3] [rpcd] file: add append write support

2016-04-11 Thread Luka Perkov
Signed-off-by: Luka Perkov 
---
 file.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/file.c b/file.c
index d983518..91a55a1 100644
--- a/file.c
+++ b/file.c
@@ -93,6 +93,7 @@ static const struct blobmsg_policy 
rpc_file_rb_policy[__RPC_F_RB_MAX] = {
 enum {
RPC_F_RW_PATH,
RPC_F_RW_DATA,
+   RPC_F_RW_APPEND,
RPC_F_RW_MODE,
RPC_F_RW_BASE64,
__RPC_F_RW_MAX,
@@ -101,6 +102,7 @@ enum {
 static const struct blobmsg_policy rpc_file_rw_policy[__RPC_F_RW_MAX] = {
[RPC_F_RW_PATH]   = { .name = "path",   .type = BLOBMSG_TYPE_STRING },
[RPC_F_RW_DATA]   = { .name = "data",   .type = BLOBMSG_TYPE_STRING },
+   [RPC_F_RW_APPEND] = { .name = "append", .type = BLOBMSG_TYPE_BOOL  },
[RPC_F_RW_MODE]   = { .name = "mode",   .type = BLOBMSG_TYPE_INT32  },
[RPC_F_RW_BASE64] = { .name = "base64", .type = BLOBMSG_TYPE_BOOL   },
 };
@@ -265,6 +267,7 @@ rpc_file_write(struct ubus_context *ctx, struct ubus_object 
*obj,
struct blob_attr *msg)
 {
struct blob_attr *tb[__RPC_F_RW_MAX];
+   int append = O_TRUNC;
mode_t prev_mode, mode = 0666;
int fd, rv = 0;
void *data = NULL;
@@ -279,11 +282,14 @@ rpc_file_write(struct ubus_context *ctx, struct 
ubus_object *obj,
data = blobmsg_data(tb[RPC_F_RW_DATA]);
data_len = blobmsg_data_len(tb[RPC_F_RW_DATA]) - 1;
 
+   if (tb[RPC_F_RW_APPEND] && blobmsg_get_bool(tb[RPC_F_RW_APPEND]))
+   append = O_APPEND;
+
if (tb[RPC_F_RW_MODE])
mode = blobmsg_get_u32(tb[RPC_F_RW_MODE]);
 
prev_mode = umask(0);
-   fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | 
O_TRUNC, mode);
+   fd = open(blobmsg_data(tb[RPC_F_RW_PATH]), O_CREAT | O_WRONLY | append, 
mode);
umask(prev_mode);
if (fd < 0)
return rpc_errno_status();
-- 
2.8.0
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ramips: awake rt305x USB controller

2016-04-11 Thread Сергей Василюгин
Because of Ralink uboot set USB controller into sleep mode [1]
we check it and awake controller before any registers access.
Fix ticket #21396 [2]

[1] http://marc.info/?l=linux-usb&m=137398626102108&w=2
[2] https://dev.openwrt.org/ticket/21396

Signed-Off-By: Serge Vasilugin 


diff --git 
a/target/linux/ramips/patches-4.4/0069-awake-rt305x-dwc2-controller.patch 
b/target/linux/ramips/patches-4.4/0069-awake-rt305x-dwc2-controller.patch
new file mode 100644
index 000..2ba462d
--- /dev/null
+++ b/target/linux/ramips/patches-4.4/0069-awake-rt305x-dwc2-controller.patch
@@ -0,0 +1,15 @@
+--- a/drivers/usb/dwc2/platform.c
 b/drivers/usb/dwc2/platform.c
+@@ -375,6 +375,12 @@ static int dwc2_driver_probe(struct plat
+ dev_dbg(&dev->dev, "mapped PA %08lx to VA %p\n",
+ (unsigned long)res->start, hsotg->regs);
+ 
++ /* Enable USB port before any regs access */
++ if(dwc2_readl(hsotg->regs + PCGCTL) & 0x0f) {
++ dwc2_writel(0x00, hsotg->regs + PCGCTL);
++ /* TODO: mdelay(25) here? vendor driver don't use it */
++ }
++
+ hsotg->dr_mode = usb_get_dr_mode(&dev->dev);
+ if (IS_ENABLED(CONFIG_USB_DWC2_HOST) &&
+ hsotg->dr_mode != USB_DR_MODE_HOST) {
---
serge
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [RFC relayd 1/2] relayd: add ipv6 support

2016-04-11 Thread Bjørn Mork
Michal Kazior  writes:

> This adds basic IPv6 support framework. Things
> like, e.g. DHCPv6 will not work (yeT) though
> because link-local support requires additional
> changes (including kernel).

Could the DHCPv6 support be implemented as an LDRA instead? Ref
https://tools.ietf.org/html/rfc6221


Bjørn
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] ramips: add support for ELECOM WRH-300CR

2016-04-11 Thread FUKAUMI Naoki
Signed-off-by: YuheiOKAWA 
Signed-off-by: FUKAUMI Naoki 
---
 target/linux/ramips/base-files/etc/board.d/01_leds |   4 +
 .../linux/ramips/base-files/etc/board.d/02_network |   3 +-
 target/linux/ramips/base-files/etc/diag.sh |   3 +-
 target/linux/ramips/base-files/lib/ramips.sh   |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh  |   1 +
 target/linux/ramips/dts/WRH-300CR.dts  | 126 +
 target/linux/ramips/image/mt7620.mk|  15 +++
 target/linux/ramips/mt7620/profiles/elecom.mk  |  18 +++
 8 files changed, 171 insertions(+), 2 deletions(-)
 create mode 100644 target/linux/ramips/dts/WRH-300CR.dts
 create mode 100644 target/linux/ramips/mt7620/profiles/elecom.mk

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds 
b/target/linux/ramips/base-files/etc/board.d/01_leds
index 5816e60..0ba26d2 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -264,6 +264,10 @@ whr-600d)
 wnce2001)
set_wifi_led "$board:green:wlan"
;;
+wrh-300cr)
+   set_wifi_led "$board:green:wlan"
+   ucidef_set_led_netdev "lan" "lan" "$board:green:ethernet" "eth0"
+   ;;
 wt3020)
ucidef_set_led_default "power" "power" "$board:blue:power" "0"
;;
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network 
b/target/linux/ramips/base-files/etc/board.d/02_network
index 4b65d36..2863b88 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -162,7 +162,8 @@ ramips_setup_interfaces()
d105|\
hpm|\
na930|\
-   wli-tx4-ag300n)
+   wli-tx4-ag300n|\
+   wrh-300cr)
ucidef_set_interface_lan "eth0"
;;
e1700|\
diff --git a/target/linux/ramips/base-files/etc/diag.sh 
b/target/linux/ramips/base-files/etc/diag.sh
index daa7fb1..31d9646 100644
--- a/target/linux/ramips/base-files/etc/diag.sh
+++ b/target/linux/ramips/base-files/etc/diag.sh
@@ -73,7 +73,8 @@ get_status_led() {
status_led="$board:green:run"
;;
awapn2403|\
-   dir-645)
+   dir-645|\
+   wrh-300cr)
status_led="$board:green:wps"
;;
cf-wr800n|\
diff --git a/target/linux/ramips/base-files/lib/ramips.sh 
b/target/linux/ramips/base-files/lib/ramips.sh
index 5f1df7b..459de6f 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -460,6 +460,9 @@ ramips_board_detect() {
*"WR6202")
name="wr6202"
;;
+   *"WRH-300CR")
+   name="wrh-300cr"
+   ;;
*"WRTNODE")
name="wrtnode"
;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh 
b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index c329dce..6e287d4 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -135,6 +135,7 @@ platform_check_image() {
wnce2001|\
wr512-3gn|\
wr6202|\
+   wrh-300cr|\
wrtnode|\
wrtnode2r |\
wrtnode2p |\
diff --git a/target/linux/ramips/dts/WRH-300CR.dts 
b/target/linux/ramips/dts/WRH-300CR.dts
new file mode 100644
index 000..7e1947d
--- /dev/null
+++ b/target/linux/ramips/dts/WRH-300CR.dts
@@ -0,0 +1,126 @@
+/dts-v1/;
+
+/include/ "mt7620n.dtsi"
+
+/ {
+   compatible = "elecom,wrh-300cr", "ralink,mt7620n-soc";
+   model = "ELECOM WRH-300CR";
+
+   palmbus@1000 {
+   gpio1: gpio@638 {
+   status = "okay";
+   };
+
+   gpio2: gpio@660 {
+   status = "okay";
+   };
+
+   gpio3: gpio@688 {
+   status = "okay";
+   };
+
+   spi@b00 {
+   status = "okay";
+
+   m25p80@0 {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "jedec,spi-nor";
+   reg = <0 0>;
+   linux,modalias = "m25p80", "mx25l12805d";
+   spi-max-frequency = <1000>;
+
+   partition@0 {
+   label = "u-boot";
+   reg = <0x0 0x3>;
+   read-only;
+   };
+
+   partition@3 {
+   label = "u-boot-env";
+   reg = <0x3 0x1>;
+   };
+
+   factory: partition@4 {
+   label = "factor

[OpenWrt-Devel] [PATCH] CC: ramips: backport rt3352 usbphy fix in dts-file

2016-04-11 Thread Сергей Василюгин
Backport of trunk patch. Fix kernel hang during loading ehci-hcd module.

SIgned-Off-By: Serge Vasilugin 

diff --git a/target/linux/ramips/dts/rt3352.dtsi 
b/target/linux/ramips/dts/rt3352.dtsi
index 7dffddb..dacb047 100644
--- a/target/linux/ramips/dts/rt3352.dtsi
+++ b/target/linux/ramips/dts/rt3352.dtsi
@@ -222,8 +222,9 @@
interrupts = <17>;
};
 
-   usbphy {
+   usbphy: usbphy {
compatible = "ralink,rt3xxx-usbphy";
+   #phy-cells = <1>;
 
resets = <&rstctrl 22 &rstctrl 25>;
reset-names = "host", "device";
@@ -243,6 +244,9 @@
compatible = "ralink,rt3xxx-ehci", "ehci-platform";
reg = <0x101c 0x1000>;
 
+   phys = <&usbphy 1>;
+   phy-names = "usb";
+
interrupt-parent = <&intc>;
interrupts = <18>;
 
@@ -253,6 +257,9 @@
compatible = "ralink,rt3xxx-ohci", "ohci-platform";
reg = <0x101c1000 0x1000>;
 
+   phys = <&usbphy 1>;
+   phy-names = "usb";
+
interrupt-parent = <&intc>;
interrupts = <18>;
 

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


[OpenWrt-Devel] [RFC relayd 1/2] relayd: add ipv6 support

2016-04-11 Thread Michal Kazior
This adds basic IPv6 support framework. Things
like, e.g. DHCPv6 will not work (yeT) though
because link-local support requires additional
changes (including kernel).

Signed-off-by: Michal Kazior 
---
 dhcp.c   |  30 +--
 main.c   | 730 +++
 relayd.h |  59 +-
 route.c  | 184 +++-
 4 files changed, 876 insertions(+), 127 deletions(-)

diff --git a/dhcp.c b/dhcp.c
index aefe34fd80e6..a915cf88e97f 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -55,32 +55,6 @@ struct dhcp_header {
uint8_t option_data[];
 } __packed;
 
-static uint16_t
-chksum(uint16_t sum, const uint8_t *data, uint16_t len)
-{
-   const uint8_t *last;
-   uint16_t t;
-
-   last = data + len - 1;
-
-   while(data < last) {
-   t = (data[0] << 8) + data[1];
-   sum += t;
-   if(sum < t)
-   sum++;
-   data += 2;
-   }
-
-   if(data == last) {
-   t = (data[0] << 8) + 0;
-   sum += t;
-   if(sum < t)
-   sum++;
-   }
-
-   return sum;
-}
-
 static void
 parse_dhcp_options(struct relayd_host *host, struct dhcp_header *dhcp, int len)
 {
@@ -99,7 +73,7 @@ parse_dhcp_options(struct relayd_host *host, struct 
dhcp_header *dhcp, int len)
if (!memcmp(opt->data, host->ipaddr, 4))
relayd_add_host_route(host, dest, 0);
else
-   relayd_add_pending_route(opt->data, dest, 0, 
1);
+   relayd_add_pending_route(opt->data, dest, 0, 
1, AF_INET);
break;
case DHCP_OPTION_ROUTES:
DPRINTF(2, "Found a DHCP static routes option, 
len=%d\n", opt->len);
@@ -150,7 +124,7 @@ bool relayd_handle_dhcp_packet(struct relayd_interface 
*rif, void *data, int len
return true;
 
if (dhcp->op == 2) {
-   host = relayd_refresh_host(rif, pkt->eth.ether_shost, (void *) 
&pkt->iph.saddr);
+   host = relayd_refresh_host(rif, pkt->eth.ether_shost, (void *) 
&pkt->iph.saddr, AF_INET);
if (host && parse)
parse_dhcp_options(host, dhcp, udplen - sizeof(struct 
udphdr));
}
diff --git a/main.c b/main.c
index b3c13f7f7a49..e1d1dc997b6f 100644
--- a/main.c
+++ b/main.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "relayd.h"
 
@@ -41,6 +42,7 @@ static int inet_sock;
 static int forward_bcast;
 static int forward_dhcp;
 static int parse_dhcp;
+static int ipv6;
 
 uint8_t local_addr[4];
 int local_route_table;
@@ -48,16 +50,296 @@ int local_route_table;
 struct relayd_pending_route {
struct relayd_route rt;
struct uloop_timeout timeout;
-   uint8_t gateway[4];
+   union {
+   uint8_t gateway[16];
+   uint16_t gateway16[8];
+   };
 };
 
-static struct relayd_host *find_host_by_ipaddr(struct relayd_interface *rif, 
const uint8_t *ipaddr)
+/* Generated with: tcpdump -dd ip6 proto 58 or ip6 multicast */
+static struct sock_filter ip6bpf[] = {
+   { 0x28, 0, 0, 0x000c },
+   { 0x15, 0, 8, 0x86dd },
+   { 0x30, 0, 0, 0x0014 },
+   { 0x15, 5, 0, 0x003a },
+   { 0x15, 0, 2, 0x002c },
+   { 0x30, 0, 0, 0x0036 },
+   { 0x15, 2, 0, 0x003a },
+   { 0x30, 0, 0, 0x0026 },
+   { 0x15, 0, 1, 0x00ff },
+   { 0x6, 0, 0, 0x0004 },
+   { 0x6, 0, 0, 0x },
+};
+static const struct sock_fprog ip6bpf_prog = {
+   sizeof(ip6bpf) / sizeof(ip6bpf[0]),
+   ip6bpf,
+};
+
+uint16_t chksum(uint16_t sum, const uint8_t *data, uint16_t len)
+{
+   const uint8_t *last;
+   uint16_t t;
+
+   last = data + len - 1;
+
+   while(data < last) {
+   t = (data[0] << 8) + data[1];
+   sum += t;
+   if(sum < t)
+   sum++;
+   data += 2;
+   }
+
+   if(data == last) {
+   t = (data[0] << 8) + 0;
+   sum += t;
+   if(sum < t)
+   sum++;
+   }
+
+   return sum;
+}
+
+static void icmp6_chksum(struct ether_header *eth,
+struct ip6_hdr *ip6,
+struct icmp6_hdr *icmp6,
+int pktlen)
+{
+   unsigned char sumbuf[16 + 16 + 4 + 4];
+   uint16_t sum;
+   unsigned int uplen;
+
+   uplen = pktlen - ((void *)icmp6 - (void *)eth);
+   uplen = htonl(uplen);
+   memcpy(&sumbuf[0],  &ip6->ip6_src, 16);
+   memcpy(&sumbuf[16], &ip6->ip6_dst, 16);
+   memcpy(&sumbuf[32], &uplen, 4);
+   memset(&sumbuf[36], 0, 3);
+   memcpy(&sumbuf[39], &ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt, 1);
+
+   icmp6->icmp6_cksum = 0;
+   uplen = ntohl(uplen);
+   sum = chksum(0, (void *)sumbuf, 40);
+   sum = chk

[OpenWrt-Devel] [RFC relayd 2/2] relayd: add ipv6 link local support

2016-04-11 Thread Michal Kazior
This patch combined with an corresponding kernel
patch makes it possible to route link-local
addresses which, in practice, means DHCPv6, RA, RS
are now functional.

Signed-off-by: Michal Kazior 
---
 main.c  |  3 +++
 route.c | 22 ++
 2 files changed, 25 insertions(+)

diff --git a/main.c b/main.c
index e1d1dc997b6f..30906b2df2e9 100644
--- a/main.c
+++ b/main.c
@@ -1341,6 +1341,9 @@ static int usage(const char *progname)
"   -P  Disable DHCP options parsing\n"
"   -L  Enable local access using 
 as source address\n"
"   -6  Enable IPv6 support\n"
+#ifdef RTAX_FEATURE_XFACE
+   "IPv6 link-local routing capability is compiled in.\n"
+#endif
"\n",
progname);
return -1;
diff --git a/route.c b/route.c
index fc15e9945aaf..05d8cee18214 100644
--- a/route.c
+++ b/route.c
@@ -191,6 +191,13 @@ rtnl_route_request(struct relayd_interface *rif, struct 
relayd_host *host,
struct rtattr rta;
int ifindex;
} __packed dev;
+   struct {
+   struct rtattr rta;
+   struct {
+   struct rtattr rta;
+   int val;
+   } __packed features;
+   } __packed metrics;
union {
struct rtnl_addr4 addr4[3];
struct rtnl_addr6 addr6[3];
@@ -209,6 +216,21 @@ rtnl_route_request(struct relayd_interface *rif, struct 
relayd_host *host,
.rta_type = RTA_OIF,
.rta_len = sizeof(req.dev),
},
+   .metrics = {
+   .rta = {
+   .rta_type = RTA_METRICS,
+   .rta_len = sizeof(req.metrics),
+   },
+   .features = {
+   .rta = {
+   .rta_type = RTAX_FEATURES,
+   .rta_len = sizeof(req.metrics.features),
+   },
+#ifdef RTAX_FEATURE_XFACE
+   .val = RTAX_FEATURE_XFACE,
+#endif
+   },
+   },
};
int pktlen = sizeof(req) - sizeof(req.addrs);
void *addrs = &req.addrs;
-- 
2.1.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [RFC relayd 0/2] relayd: add ipv6 support

2016-04-11 Thread Michal Kazior
Hi,

I've been recently working on adding IPv6 support
to relayd (which supported only IPv4).

It does, however, require a kernel patch to make
it actually usable because link-local addresses
are not routable by kernel by default.

The patch, currently an RFC, can be found here:

  https://www.mail-archive.com/netdev@vger.kernel.org/msg104390.html

Merging this relayd change probably doesn't make
much sense until the kernel patch is accepted.


Michal Kazior (2):
  relayd: add ipv6 support
  relayd: add ipv6 link local support

 dhcp.c   |  30 +--
 main.c   | 733 +++
 relayd.h |  59 -
 route.c  | 206 +-
 4 files changed, 901 insertions(+), 127 deletions(-)

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


[OpenWrt-Devel] [PATCH] brcm63xx: fix external IRQs

2016-04-11 Thread dani
External IRQs are currently broken, fix the BCM6345_EXT_IRQ driver.

Since the adoption of the new driver irq-bcm6345-ext, in Chaos Calmer,
external IRQs don't work. It seems there were some minor errors at the initial
development of the driver.

This patch fixes the ticket https://dev.openwrt.org/ticket/21613

Signed-off-by: Daniel Gonzalez 
diff --git 
a/target/linux/brcm63xx/patches-4.1/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
 
b/target/linux/brcm63xx/patches-4.1/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
index 5ee5ee2..4dd5130 100644
--- 
a/target/linux/brcm63xx/patches-4.1/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
+++ 
b/target/linux/brcm63xx/patches-4.1/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
@@ -148,7 +148,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg |= hwirq << (EXTIRQ_CFG_CLEAR * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_CLEAR * priv->shift);
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -161,7 +161,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg &= ~(hwirq << (EXTIRQ_CFG_MASK * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_MASK * priv->shift));
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -174,7 +174,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg |= hwirq << (EXTIRQ_CFG_MASK * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_MASK * priv->shift);
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -222,17 +222,17 @@ Signed-off-by: Jonas Gorski 
 +  reg = __raw_readl(priv->reg);
 +
 +  if (levelsense)
-+  reg |= hwirq << (EXTIRQ_CFG_LEVELSENSE * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_LEVELSENSE * priv->shift);
 +  else
-+  reg &= ~(hwirq << (EXTIRQ_CFG_LEVELSENSE * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_LEVELSENSE * priv->shift));
 +  if (sense)
-+  reg |= hwirq << (EXTIRQ_CFG_SENSE * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_SENSE * priv->shift);
 +  else
-+  reg &= ~(hwirq << (EXTIRQ_CFG_SENSE * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_SENSE * priv->shift));
 +  if (bothedge)
-+  reg |= hwirq << (EXTIRQ_CFG_BOTHEDGE * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_BOTHEDGE * priv->shift);
 +  else
-+  reg &= ~(hwirq << (EXTIRQ_CFG_BOTHEDGE * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_BOTHEDGE * priv->shift));
 +
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
diff --git 
a/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
 
b/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
index 4f4d7bd..2526456 100644
--- 
a/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
+++ 
b/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
@@ -148,7 +148,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg |= hwirq << (EXTIRQ_CFG_CLEAR * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_CLEAR * priv->shift);
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -161,7 +161,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg &= ~(hwirq << (EXTIRQ_CFG_MASK * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_MASK * priv->shift));
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -174,7 +174,7 @@ Signed-off-by: Jonas Gorski 
 +
 +  raw_spin_lock(&priv->lock);
 +  reg = __raw_readl(priv->reg);
-+  reg |= hwirq << (EXTIRQ_CFG_MASK * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_MASK * priv->shift);
 +  __raw_writel(reg, priv->reg);
 +  raw_spin_unlock(&priv->lock);
 +}
@@ -222,17 +222,17 @@ Signed-off-by: Jonas Gorski 
 +  reg = __raw_readl(priv->reg);
 +
 +  if (levelsense)
-+  reg |= hwirq << (EXTIRQ_CFG_LEVELSENSE * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_LEVELSENSE * priv->shift);
 +  else
-+  reg &= ~(hwirq << (EXTIRQ_CFG_LEVELSENSE * priv->shift));
++  reg &= ~(1 << (hwirq + EXTIRQ_CFG_LEVELSENSE * priv->shift));
 +  if (sense)
-+  reg |= hwirq << (EXTIRQ_CFG_SENSE * priv->shift);
++  reg |= 1 << (hwirq + EXTIRQ_CFG_SENSE * priv->shift);
 +  else
-+  reg &= ~(hwirq << (EXTIRQ_CFG_SENSE * priv

[OpenWrt-Devel] [PATCH] ubus: cli.wait_for: add polling for services

2016-04-11 Thread Zefir Kurtisi
In ubus_cli_wait_for() there is a potential critical section
between initially checking for the requested services and
the following handling of 'ubus.object.add' events.

In our system we let procd (re)start services and synchronize
inter-service dependencies by using 'ubus wait_for' in the
initscripts' service_started() functions. There we observe
randomly that 'wait_for' is waiting for the full timeout
and returning UBUS_STATUS_TIMEOUT, even if the service it
is waiting for is already up and running.

This happens when the service is started in the critical
section mentioned above.

The proposed patch adds periodic lookup for the requested
services while waiting for the 'add' event and with that
fixes the observed failure.

Signed-off-by: Zefir Kurtisi 
---
 cli.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/cli.c b/cli.c
index c5cbfc3..8d98b12 100644
--- a/cli.c
+++ b/cli.c
@@ -16,6 +16,7 @@
 #include 
 #include "libubus.h"
 
+static struct ubus_context *ctx;
 static struct blob_buf b;
 static int timeout = 30;
 static bool simple_output = false;
@@ -277,15 +278,27 @@ static void wait_timeout(struct uloop_timeout *timeout)
uloop_end();
 }
 
-static int ubus_cli_wait_for(struct ubus_context *ctx, int argc, char **argv)
-{
-   struct cli_wait_data data = {
+#define WAIT_LOOP_TIME 200
+static struct cli_wait_data data = {
.timeout.cb = wait_timeout,
.ev.cb = wait_event_cb,
-   .pending = argv,
-   .n_pending = argc,
-   };
+};
+
+static void poll_timeout_cb(struct uloop_timeout *timeout)
+{
+   int ret = ubus_lookup(ctx, NULL, wait_list_cb, &data);
+   if (ret || !data.n_pending) {
+   uloop_end();
+   return;
+   }
+   uloop_timeout_set(timeout, WAIT_LOOP_TIME);
+}
+static int ubus_cli_wait_for(struct ubus_context *ctx, int argc, char **argv)
+{
+   data.pending = argv;
+   data.n_pending = argc;
int ret;
+   static struct uloop_timeout poll_timeout = { .cb = poll_timeout_cb, };
 
if (argc < 1)
return -2;
@@ -305,6 +318,7 @@ static int ubus_cli_wait_for(struct ubus_context *ctx, int 
argc, char **argv)
return ret;
 
uloop_timeout_set(&data.timeout, timeout * 1000);
+   uloop_timeout_set(&poll_timeout, WAIT_LOOP_TIME);
uloop_run();
uloop_done();
 
@@ -509,7 +523,6 @@ static struct {
 int main(int argc, char **argv)
 {
const char *progname, *ubus_socket = NULL;
-   struct ubus_context *ctx;
char *cmd;
int ret = 0;
int i, ch;
-- 
2.7.4
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] ramips: mt7621: add support for disabling flow control

2016-04-11 Thread Cristian Morales Vega
Sorry, for some reason I didn't receive your reply (but patchwork told
me about it), so I am replying here.

Maybe it's something that should be done with ethtool, but I had no
idea those phys were exposed through anything other than swconfig.
What would be the "DEVNAME" in "ethtool -a DEVNAME" if I want to, for
example, check the settings of the switch port #3?


On 5 April 2016 at 15:22, Cristian Morales Vega  wrote:
> Signed-off-by: Cristian Morales Vega 
> ---
>  ...diatek-add-swconfig-driver-for-gsw_mt762x.patch | 54 
> +-
>  1 file changed, 53 insertions(+), 1 deletion(-)
>
> diff --git 
> a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
>  
> b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> index bbad8cc..d056551 100644
> --- 
> a/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> +++ 
> b/target/linux/ramips/patches-4.4/0513-net-mediatek-add-swconfig-driver-for-gsw_mt762x.patch
> @@ -28,7 +28,7 @@ Signed-off-by: John Crispin 
>   obj-$(CONFIG_NET_MEDIATEK_SOC)+= mtk-eth-soc.o
>  --- /dev/null
>  +++ b/drivers/net/ethernet/mediatek/mt7530.c
> -@@ -0,0 +1,804 @@
> +@@ -0,0 +1,856 @@
>  +/*
>  + * This program is free software; you can redistribute it and/or
>  + * modify it under the terms of the GNU General Public License
> @@ -709,6 +709,50 @@ Signed-off-by: John Crispin 
>  +  return 0;
>  +}
>  +
> ++static int mt7621_sw_get_port_fc(struct switch_dev *dev,
> ++   const struct switch_attr *attr,
> ++   struct switch_val *val)
> ++{
> ++  u32 reg;
> ++  struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, 
> swdev);
> ++
> ++  if (val->port_vlan >= MT7530_NUM_PORTS)
> ++  return -EINVAL;
> ++
> ++  reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++  reg &= BIT(10);
> ++
> ++  val->value.i = reg ? 1 : 0;
> ++
> ++  return 0;
> ++}
> ++
> ++static int mt7621_sw_set_port_fc(struct switch_dev *dev,
> ++   const struct switch_attr *attr,
> ++   struct switch_val *val)
> ++{
> ++  u32 reg;
> ++  struct mt7530_priv *priv = container_of(dev, struct mt7530_priv, 
> swdev);
> ++
> ++  if (val->port_vlan >= MT7530_NUM_PORTS)
> ++  return -EINVAL;
> ++
> ++  reg = mdiobus_read(priv->bus, val->port_vlan, 4);
> ++  if(val->value.i) {
> ++  reg |= BIT(10);
> ++  } else {
> ++  reg &= ~BIT(10);
> ++  }
> ++  mdiobus_write(priv->bus, val->port_vlan, 4, reg);
> ++
> ++  /* Restart auto-negotiation */
> ++  reg = mdiobus_read(priv->bus, val->port_vlan, 0);
> ++  reg |= BIT(9);
> ++  mdiobus_write(priv->bus, val->port_vlan, 0, reg);
> ++
> ++  return 0;
> ++}
> ++
>  +static const struct switch_attr mt7621_port[] = {
>  +  {
>  +  .type = SWITCH_TYPE_STRING,
> @@ -717,6 +761,14 @@ Signed-off-by: John Crispin 
>  +  .get = mt7621_sw_get_port_mib,
>  +  .set = NULL,
>  +  },
> ++  {
> ++  .type = SWITCH_TYPE_INT,
> ++  .name = "flow_ctl",
> ++  .description = "Flow Control",
> ++  .get = mt7621_sw_get_port_fc,
> ++  .set = mt7621_sw_set_port_fc,
> ++  .max = 1,
> ++  },
>  +};
>  +
>  +static const struct switch_attr mt7530_port[] = {
> --
> 2.6.3
>



-- 
Cristian Morales Vega

Email crist...@samknows.com
Office +44 (0) 20 3111 4330
Web:  www.samknows.com


This email is sent for and on behalf of SamKnows Limited.

This email and any attachments are confidential, legally privileged
and protected by copyright. If you are not the intended recipient
dissemination or copying of this email is prohibited. If you have
received this in error, please notify the sender by replying by email
and then delete the email completely from your system.

SamKnows Limited, Registered Number: 06510477, Registered Office: Hill
House, 1 Little New Street, London, EC4A 3TR. Registered in England
and Wales. Trade Mark 2507103
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel