mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [RFC 00/12] barebox picotcp integration (2015.07.15)
@ 2015-07-15 20:13 Antony Pavlov
  2015-07-15 20:13 ` [RFC 01/12] picotcp: add barebox target support Antony Pavlov
                   ` (11 more replies)
  0 siblings, 12 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

I have just published latest picotcp-enabled barebox.
Please see my 20150715.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150715.picotcp).

This version is based on the latest barebox-next and picotcp v1.5.0
(there is also picotcp v1.5.1, but is has no interested
for barebox changes since v1.5.0).

Changes since 2015.06.14 (see http://lists.infradead.org/pipermail/barebox/2015-June/023749.html):

  * drop picotcp tftp support;
    make it possible to use some barebox' network applications
    on top of picotcp udp packet ip:

      * use barebox' tftp support on top of picotcp;
      * use barebox' nfs support on top of picotcp;
      * use barebox' dns support on top of picotcp;

    Anyway new 'picoping' command uses picotcp ICMP support
    because it makes possible to realize traditional *NIX 'ping'
    program behaviour in barebox.

  * drop all unused picotcp files;

  * import picotcp dhcp stuff temporary skipped
    we can revive it in any moment but
    it's better to adapt barebox' dhcp implementation;

Here is note/todo list:

  1. with picotcp we can't easely use 'tftp' command with old syntax
     (no $<current network interface>.serverip anymore);

  2. just now picotcp-based tftp/nfs file transfer is slower than
     old realisation (partialy it is my bad, e.g. extra memory copy operation
     is used for code simplification); see Very Simple Benchmarks below for details;

  3. rework barebox dhcp, ifup and netconsole realization for working on top of picotcp.


Very Simple Benchmarks
======================

I have sandbox barebox (192.168.1.2) and nfs- and tftp- servers on the same host (192.168.1.1).
I copy 16MiB (16777216 bytes) file from server to sandbox barebox over network several times.
I use time command inside sandox barebox for computing transfer time.

barebox at barebox sandbox:/ eth0.ipaddr=192.168.1.2
barebox at barebox sandbox:/ mount -t tftp 192.168.1.1 /mnt
...
barebox at barebox sandbox:/ time cp /mnt/16M .
time: 546ms

Here is typical transfer time values:

+--------+--------------+--------------+
|        |   U-boot     |   picotcp    |
|        |    stack     |    stack     |
+--------+--------------+--------------+
|        |              |              |
|  tftp  |    546ms     |    859ms     |
|        |              |              |
+--------+--------------+--------------+
|        |              |              |
|  nfs   |   1037ms     |   1393ms     |
|        |              |              |
+--------+--------------+--------------+

There are some rather simple possibilities to slighly improve picotcp-barebox performance:

  * drop extra memory copy;
  * drop extra pico_tick() calls (is_timeout() calls poller_call(), so there is no need
                                  to call poller_call() explicitly in nfs/tftp code);
  * there is an issue with sustained tftp small file copy. E.g.

         barebox at barebox sandbox:/ ifconfig eth 192.168.1.2 255.255.255.0
         Assigned ipv4 192.168.1.2 to device eth
         barebox at barebox sandbox:/ mount -t tftp 192.168.1.1 /mnt
         barebox at barebox sandbox:/ while true; do time cp /mnt/1M . ; done
         ...
         Warning: I have 122 timers
         Warning: I have 121 timers
         time: 48ms
         Warning: I have 122 timers
         Warning: I have 121 timers
         time: 53ms
         Warning: I have 122 timers
         Warning: I have 121 timers
         time: 54ms


Antony Pavlov (12):
  picotcp: add barebox target support
  picotcp: switch to Kbuild
  net: add initial picotcp support
  WIP: fs/nfs.c: convert to picotcp
  WIP: fs/tftp.c: convert to picotcp
  WIP: net/dns: convert to picotcp
  net: picotcp: add test_picotcp command
  net: picotcp: add ifconfig command
  net: picotcp: add ping command
  net: picotcp: add route command
  sandbox_defconfig: switch to picotcp
  WIP: sandbox_defconfig: enable network testing-related stuff

 Makefile                                |   1 +
 arch/sandbox/configs/sandbox_defconfig  |  12 ++
 commands/Kconfig                        |   4 +
 fs/nfs.c                                | 150 +++++++++++++++++++++---
 fs/tftp.c                               | 199 ++++++++++++++++++++++++++++----
 include/net.h                           |   3 +
 include/pico_defines.h                  |   0
 include/stdint.h                        |   1 +
 net/Kconfig                             |  17 +++
 net/Makefile                            |   8 ++
 net/dns.c                               | 101 ++++++++++++++--
 net/eth.c                               |  71 ++++++++++++
 net/net.c                               |  10 ++
 net/picotcp.c                           |  20 ++++
 net/picotcp/.gitignore                  |   1 +
 net/picotcp/Kconfig                     |  56 +++++++++
 net/picotcp/Makefile                    |  30 +++++
 net/picotcp/include/arch/pico_barebox.h |  76 ++++++++++++
 net/picotcp/include/pico_config.h       |   2 +
 net/picotcp/modules/Makefile            |   8 ++
 net/picotcp/stack/Makefile              |   7 ++
 net/picotcp_ifconfig.c                  | 116 +++++++++++++++++++
 net/picotcp_ping.c                      |  85 ++++++++++++++
 net/picotcp_route.c                     |  37 ++++++
 net/picotcp_test_ipv4.c                 |  96 +++++++++++++++
 25 files changed, 1063 insertions(+), 48 deletions(-)
 create mode 100644 include/pico_defines.h
 create mode 100644 include/stdint.h
 create mode 100644 net/picotcp.c
 create mode 100644 net/picotcp/Kconfig
 create mode 100644 net/picotcp/Makefile
 create mode 100644 net/picotcp/include/arch/pico_barebox.h
 create mode 100644 net/picotcp/modules/Makefile
 create mode 100644 net/picotcp/stack/Makefile
 create mode 100644 net/picotcp_ifconfig.c
 create mode 100644 net/picotcp_ping.c
 create mode 100644 net/picotcp_route.c
 create mode 100644 net/picotcp_test_ipv4.c

-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 01/12] picotcp: add barebox target support
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 02/12] picotcp: switch to Kbuild Antony Pavlov
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/picotcp/include/arch/pico_barebox.h | 76 +++++++++++++++++++++++++++++++++
 net/picotcp/include/pico_config.h       |  2 +
 2 files changed, 78 insertions(+)

diff --git a/net/picotcp/include/arch/pico_barebox.h b/net/picotcp/include/arch/pico_barebox.h
new file mode 100644
index 0000000..11e6ed3
--- /dev/null
+++ b/net/picotcp/include/arch/pico_barebox.h
@@ -0,0 +1,76 @@
+#ifndef PICO_SUPPORT_BAREBOX
+#define PICO_SUPPORT_BAREBOX
+
+#include <string.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <clock.h>
+#include <linux/math64.h>
+
+/*
+   #define MEMORY_MEASURE
+ */
+#define dbg printf
+
+#define stack_fill_pattern(...) do {} while(0)
+#define stack_count_free_words(...) do {} while(0)
+#define stack_get_free_words() (0)
+
+/* measure allocated memory */
+#ifdef MEMORY_MEASURE
+extern uint32_t max_mem;
+extern uint32_t cur_mem;
+
+static inline void *pico_zalloc(int x)
+{
+    uint32_t *ptr;
+    if ((cur_mem + x) > (10 * 1024))
+        return NULL;
+
+    ptr = (uint32_t *)calloc(x + 4, 1);
+    *ptr = (uint32_t)x;
+    cur_mem += x;
+    if (cur_mem > max_mem) {
+        max_mem = cur_mem;
+    }
+
+    return (void*)(ptr + 1);
+}
+
+static inline void pico_free(void *x)
+{
+    uint32_t *ptr = (uint32_t*)(((uint8_t *)x) - 4);
+    cur_mem -= *ptr;
+    free(ptr);
+}
+#else
+
+#define pico_zalloc(x) calloc(x, 1)
+#define pico_free(x) free(x)
+#endif
+
+static inline uint32_t PICO_TIME(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000000);
+
+    return (uint32_t) time;
+}
+
+static inline uint32_t PICO_TIME_MS(void)
+{
+    uint64_t time;
+
+    time = get_time_ns();
+    do_div(time, 1000000);
+
+    return (uint32_t) time;
+}
+
+static inline void PICO_IDLE(void)
+{
+}
+
+#endif /* PICO_SUPPORT_BAREBOX */
diff --git a/net/picotcp/include/pico_config.h b/net/picotcp/include/pico_config.h
index 6b9c040..79aaadc 100644
--- a/net/picotcp/include/pico_config.h
+++ b/net/picotcp/include/pico_config.h
@@ -211,6 +211,8 @@ static inline uint64_t long_long_be(uint64_t le)
 # include "arch/pico_none.h"
 #elif defined GENERIC
 # include "arch/pico_generic_gcc.h"
+#elif defined __BAREBOX__
+# include "arch/pico_barebox.h"
 #elif defined __KERNEL__
 # include "arch/pico_linux.h"
 /* #elif defined ... */
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 02/12] picotcp: switch to Kbuild
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
  2015-07-15 20:13 ` [RFC 01/12] picotcp: add barebox target support Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 03/12] net: add initial picotcp support Antony Pavlov
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/picotcp/.gitignore       |  1 +
 net/picotcp/Kconfig          | 34 ++++++++++++++++++++++++++++++++++
 net/picotcp/Makefile         | 30 ++++++++++++++++++++++++++++++
 net/picotcp/modules/Makefile |  8 ++++++++
 net/picotcp/stack/Makefile   |  7 +++++++
 5 files changed, 80 insertions(+)

diff --git a/net/picotcp/.gitignore b/net/picotcp/.gitignore
index 88593da..10f36c8 100644
--- a/net/picotcp/.gitignore
+++ b/net/picotcp/.gitignore
@@ -22,3 +22,4 @@ cscope.out
 *.gcov
 *.gcda
 *.gcno
+*.o.cmd
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
new file mode 100644
index 0000000..3882984
--- /dev/null
+++ b/net/picotcp/Kconfig
@@ -0,0 +1,34 @@
+if NET_PICOTCP
+
+config NET_PICO_SUPPORT_IPV4
+	bool
+	default y if NET_PICOTCP
+
+config NET_PICO_SUPPORT_IPFRAG
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+config NET_PICO_SUPPORT_ICMP4
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+config NET_PICO_SUPPORT_UDP
+	bool
+	default y if NET_PICO_SUPPORT_IPV4
+
+
+config NET_PICO_SUPPORT_ETH
+	bool
+	default y if NET_PICOTCP
+
+config NET_PICO_SUPPORT_DEVLOOP
+	bool
+	default y if NET_PICOTCP
+
+comment "Misc options"
+
+config NET_PICO_BIGENDIAN
+	bool
+	prompt "bigendian picotcp"
+
+endif # NET_PICOTCP
diff --git a/net/picotcp/Makefile b/net/picotcp/Makefile
new file mode 100644
index 0000000..8127453
--- /dev/null
+++ b/net/picotcp/Makefile
@@ -0,0 +1,30 @@
+ifeq ($(CONFIG_NET_PICO_SUPPORT_IPV4),y)
+CPPFLAGS += -DPICO_SUPPORT_IPV4
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_ICMP4),y)
+CPPFLAGS += -DPICO_SUPPORT_ICMP4 -DPICO_SUPPORT_PING
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_IPFRAG),y)
+CPPFLAGS += -DPICO_SUPPORT_IPFRAG
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_UDP),y)
+CPPFLAGS += -DPICO_SUPPORT_UDP
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_ETH),y)
+CPPFLAGS += -DPICO_SUPPORT_ETH
+endif
+
+ifeq ($(CONFIG_NET_PICO_SUPPORT_DEVLOOP),y)
+CPPFLAGS += -DPICO_SUPPORT_DEVLOOP
+endif
+
+ifeq ($(CONFIG_NET_PICO_BIGENDIAN),y)
+CPPFLAGS += -DPICO_BIGENDIAN
+endif
+
+obj-y += modules/
+obj-y += stack/
diff --git a/net/picotcp/modules/Makefile b/net/picotcp/modules/Makefile
new file mode 100644
index 0000000..2fa2261
--- /dev/null
+++ b/net/picotcp/modules/Makefile
@@ -0,0 +1,8 @@
+obj-$(CONFIG_NET_PICO_SUPPORT_IPV4) += pico_ipv4.o
+obj-$(CONFIG_NET_PICO_SUPPORT_IPFRAG) += pico_fragments.o
+obj-$(CONFIG_NET_PICO_SUPPORT_ICMP4) += pico_icmp4.o
+obj-$(CONFIG_NET_PICO_SUPPORT_UDP) += pico_udp.o pico_socket_udp.o
+
+obj-$(CONFIG_NET_PICO_SUPPORT_ETH) += pico_arp.o
+obj-$(CONFIG_NET_PICO_SUPPORT_DEVLOOP) += pico_dev_loop.o
+obj-y += pico_dev_null.o
diff --git a/net/picotcp/stack/Makefile b/net/picotcp/stack/Makefile
new file mode 100644
index 0000000..13be8d0
--- /dev/null
+++ b/net/picotcp/stack/Makefile
@@ -0,0 +1,7 @@
+obj-y += pico_device.o
+obj-y += pico_frame.o
+obj-y += pico_protocol.o
+obj-y += pico_socket.o
+obj-y += pico_socket_multicast.o
+obj-y += pico_stack.o
+obj-y += pico_tree.o
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 03/12] net: add initial picotcp support
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
  2015-07-15 20:13 ` [RFC 01/12] picotcp: add barebox target support Antony Pavlov
  2015-07-15 20:13 ` [RFC 02/12] picotcp: switch to Kbuild Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 04/12] WIP: fs/nfs.c: convert to picotcp Antony Pavlov
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox; +Cc: Daniele Lacamera

This commit adds initial picotcp support:

 * build stuff (Kbuild fixes and fake stdint.h);
 * "pico_adapter" code for connecting barebox ethernet interfaces
   to picotcp;
 * picotcp start initialization and necessary poller.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Daniele Lacamera <daniele.lacamera@tass.be>
---
 Makefile               |  1 +
 commands/Kconfig       |  4 +++
 include/net.h          |  3 +++
 include/pico_defines.h |  0
 include/stdint.h       |  1 +
 net/Kconfig            | 17 ++++++++++++
 net/Makefile           |  3 +++
 net/eth.c              | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/net.c              | 10 +++++++
 net/picotcp.c          | 20 ++++++++++++++
 10 files changed, 130 insertions(+)

diff --git a/Makefile b/Makefile
index 0fe9274..8724d08 100644
--- a/Makefile
+++ b/Makefile
@@ -292,6 +292,7 @@ export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_ve
 # Use LINUXINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
 LINUXINCLUDE    := -Iinclude -I$(srctree)/dts/include \
+                   -I$(srctree)/net/picotcp/include -I$(srctree)/net/picotcp/modules \
                    $(if $(KBUILD_SRC), -I$(srctree)/include) \
 		   -I$(srctree)/arch/$(ARCH)/include \
 		   -I$(objtree)/arch/$(ARCH)/include \
diff --git a/commands/Kconfig b/commands/Kconfig
index 5571902..77193cb 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -1184,6 +1184,7 @@ menu "Network"
 config CMD_DHCP
 	bool
 	select NET_DHCP
+	depends on NET_LEGACY
 	prompt "dhcp"
 	help
 	  DHCP client to obtain IP or boot params
@@ -1210,6 +1211,7 @@ config CMD_HOST
 config NET_CMD_IFUP
 	bool
 	prompt "ifup"
+	depends on NET_LEGACY
 	help
 	  Bring up network interfaces based on config files.
 
@@ -1237,6 +1239,7 @@ config CMD_MIITOOL
 
 config CMD_PING
 	tristate
+	depends on NET_LEGACY
 	prompt "ping"
 	help
 	  Send ICMP echo requests.
@@ -1245,6 +1248,7 @@ config CMD_PING
 
 config CMD_TFTP
 	depends on FS_TFTP
+	depends on NET_LEGACY
 	tristate
 	prompt "tftp"
 	help
diff --git a/include/net.h b/include/net.h
index b93e264..c48eceb 100644
--- a/include/net.h
+++ b/include/net.h
@@ -32,6 +32,8 @@
 
 struct device_d;
 
+#include <pico_stack.h>
+
 struct eth_device {
 	int active;
 
@@ -44,6 +46,7 @@ struct eth_device {
 	int  (*get_ethaddr) (struct eth_device*, u8 adr[6]);
 	int  (*set_ethaddr) (struct eth_device*, const unsigned char *adr);
 
+	struct pico_device *picodev;
 	struct eth_device *next;
 	void *priv;
 
diff --git a/include/pico_defines.h b/include/pico_defines.h
new file mode 100644
index 0000000..e69de29
diff --git a/include/stdint.h b/include/stdint.h
new file mode 100644
index 0000000..029276e
--- /dev/null
+++ b/include/stdint.h
@@ -0,0 +1 @@
+/* fake stdint.h for picotcp */
diff --git a/net/Kconfig b/net/Kconfig
index a890492..0099e6f 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -3,6 +3,18 @@ menuconfig NET
 
 if NET
 
+choice
+	prompt "network stack implementation"
+
+config NET_LEGACY
+	bool "legacy U-Boot network stack"
+
+config NET_PICOTCP
+	bool "picotcp network stack"
+	select POLLER
+
+endchoice
+
 config NET_NFS
 	bool
 	prompt "nfs support"
@@ -10,6 +22,7 @@ config NET_NFS
 config NET_NETCONSOLE
 	bool
 	depends on !CONSOLE_NONE
+	depends on NET_LEGACY
 	prompt "network console support"
 	help
 	  This option adds support for a simple udp based network console.
@@ -20,10 +33,14 @@ config NET_RESOLV
 
 config NET_IFUP
 	default y
+	depends on NET_LEGACY
 	bool
 
 config NET_DHCP
 	bool
+	depends on NET_LEGACY
 	prompt "dhcp support"
 
+source "net/picotcp/Kconfig"
+
 endif
diff --git a/net/Makefile b/net/Makefile
index 8d564e7..7a4597d 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -7,3 +7,6 @@ obj-$(CONFIG_CMD_PING)	+= ping.o
 obj-$(CONFIG_NET_RESOLV)+= dns.o
 obj-$(CONFIG_NET_NETCONSOLE) += netconsole.o
 obj-$(CONFIG_NET_IFUP)	+= ifup.o
+
+obj-$(CONFIG_NET_PICOTCP) += picotcp/
+obj-$(CONFIG_NET_PICOTCP) += picotcp.o
diff --git a/net/eth.c b/net/eth.c
index a090961..34358f6 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -328,6 +328,73 @@ static int eth_register_of_fixup(void)
 late_initcall(eth_register_of_fixup);
 #endif
 
+#ifdef CONFIG_NET_PICO_SUPPORT_ETH
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+
+struct pico_device_barebox_eth {
+	struct pico_device dev;
+	struct eth_device *edev;
+};
+
+static int pico_adapter_send(struct pico_device *dev, void *buf, int len)
+{
+	struct pico_device_barebox_eth *t = (struct pico_device_barebox_eth *)dev;
+	struct eth_device *edev = t->edev;
+
+	pr_debug("pico_adapter_send barebox eth (len=%d)\n", len);
+	edev->send(edev, buf, len);
+
+	return len;
+}
+
+static int pico_adapter_poll(struct pico_device *dev, int loop_score)
+{
+	struct pico_device_barebox_eth *t = (struct pico_device_barebox_eth *)dev;
+	struct eth_device *edev = t->edev;
+
+	/* pico_stack_recv(dev, buf, len) will be called from net_receive */
+
+	edev->recv(edev);
+
+	return loop_score;
+}
+
+static void pico_adapter_destroy(struct pico_device *dev)
+{
+	printf("pico_adapter_destroy barebox eth\n");
+}
+
+static void pico_adapter_init(struct eth_device *edev)
+{
+	/* FIXME: get macaddr for edev */
+	static unsigned char macaddr0[6] = { 0, 0, 0, 0xa, 0xb, 0xc };
+
+	struct pico_device_barebox_eth *pif = PICO_ZALLOC(sizeof(struct pico_device_barebox_eth));
+
+	struct pico_device *picodev;
+
+	char *name = strdup(edev->dev.name);
+
+	picodev = &pif->dev;
+	if (0 != pico_device_init(picodev, name, macaddr0)) {
+		pr_info("pico_adapter_init failed.\n");
+		pico_adapter_destroy(picodev);
+		return;
+	}
+
+	picodev->send = pico_adapter_send;
+	picodev->poll = pico_adapter_poll;
+	picodev->destroy = pico_adapter_destroy;
+
+	pif->edev = edev;
+	edev->picodev = picodev;
+
+	pr_info("Device %s created.\n", picodev->name);
+}
+#endif /* CONFIG_NET_PICO_SUPPORT_ETH */
+
 int eth_register(struct eth_device *edev)
 {
 	struct device_d *dev = &edev->dev;
@@ -388,6 +455,10 @@ int eth_register(struct eth_device *edev)
 	if (!eth_current)
 		eth_current = edev;
 
+#ifdef CONFIG_NET_PICO_SUPPORT_ETH
+	pico_adapter_init(edev);
+#endif
+
 	return 0;
 }
 
diff --git a/net/net.c b/net/net.c
index e5bd9bb..dfa916c 100644
--- a/net/net.c
+++ b/net/net.c
@@ -540,12 +540,22 @@ bad:
 	return 0;
 }
 
+#include <pico_stack.h>
+
 int net_receive(struct eth_device *edev, unsigned char *pkt, int len)
 {
 	struct ethernet *et = (struct ethernet *)pkt;
 	int et_protlen = ntohs(et->et_protlen);
 	int ret;
 
+	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pico_stack_recv(edev->picodev, pkt, len);
+
+		led_trigger_network(LED_TRIGGER_NET_RX);
+
+		return 0;
+	}
+
 	led_trigger_network(LED_TRIGGER_NET_RX);
 
 	if (len < ETHER_HDR_SIZE) {
diff --git a/net/picotcp.c b/net/picotcp.c
new file mode 100644
index 0000000..ee16a68
--- /dev/null
+++ b/net/picotcp.c
@@ -0,0 +1,20 @@
+#include <init.h>
+#include <poller.h>
+#include <pico_stack.h>
+
+static struct poller_struct picotcp_poller;
+
+static void picotcp_poller_cb(struct poller_struct *poller)
+{
+	pico_stack_tick();
+}
+
+static int picotcp_net_init(void)
+{
+	pico_stack_init();
+
+	picotcp_poller.func = picotcp_poller_cb;
+
+	return poller_register(&picotcp_poller);
+}
+postcore_initcall(picotcp_net_init);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 04/12] WIP: fs/nfs.c: convert to picotcp
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (2 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 03/12] net: add initial picotcp support Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-16 19:51   ` Sascha Hauer
  2015-07-15 20:13 ` [RFC 05/12] WIP: fs/tftp.c: " Antony Pavlov
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 fs/nfs.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 133 insertions(+), 17 deletions(-)

diff --git a/fs/nfs.c b/fs/nfs.c
index 5bff54a..f4be54a 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -37,6 +37,10 @@
 #include <byteorder.h>
 #include <globalvar.h>
 
+#include <pico_socket.h>
+#include <pico_ipv4.h>
+#include <poller.h>
+
 #include "parseopt.h"
 
 #define SUNRPC_PORT     111
@@ -131,9 +135,14 @@ struct rpc_reply {
 struct nfs_priv {
 	struct net_connection *con;
 	IPaddr_t server;
+
+	struct pico_socket *sock;
+	union pico_address remote_address;
+	uint8_t *pkt;
+
 	char *path;
-	unsigned short mount_port;
-	unsigned short nfs_port;
+	uint16_t mount_port;
+	uint16_t nfs_port;
 	uint32_t rpc_id;
 	uint32_t rootfh_len;
 	char rootfh[NFS3_FHSIZE];
@@ -383,10 +392,16 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,
 	struct rpc_call pkt;
 	unsigned short dport;
 	int ret;
-	unsigned char *payload = net_udp_get_payload(npriv->con);
+	unsigned char *payload;
 	int nfserr;
 	int tries = 0;
 
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		payload = net_udp_get_payload(npriv->con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		payload = npriv->pkt;
+	}
+
 	npriv->rpc_id++;
 
 	pkt.id = hton32(npriv->rpc_id);
@@ -398,7 +413,11 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,
 	debug("%s: prog: %d, proc: %d\n", __func__, rpc_prog, rpc_proc);
 
 	if (rpc_prog == PROG_PORTMAP) {
-		dport = SUNRPC_PORT;
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			dport = SUNRPC_PORT;
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			dport = hton16(SUNRPC_PORT);
+		}
 		pkt.vers = hton32(2);
 	} else if (rpc_prog == PROG_MOUNT) {
 		dport = npriv->mount_port;
@@ -408,14 +427,25 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,
 		pkt.vers = hton32(3);
 	}
 
+	/* FIXME: picotcp can skip extra copy here */
 	memcpy(payload, &pkt, sizeof(pkt));
 	memcpy(payload + sizeof(pkt), data, datalen * sizeof(uint32_t));
 
-	npriv->con->udp->uh_dport = hton16(dport);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		npriv->con->udp->uh_dport = hton16(dport);
+	}
 
 again:
-	ret = net_udp_send(npriv->con,
+
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		ret = net_udp_send(npriv->con,
 			sizeof(pkt) + datalen * sizeof(uint32_t));
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: picotcp ret code meaning is different */
+		ret = pico_socket_sendto(npriv->sock, npriv->pkt,
+			sizeof(pkt) + datalen * sizeof(uint32_t),
+			&npriv->remote_address, dport);
+	}
 
 	nfs_timer_start = get_time_ns();
 
@@ -427,7 +457,13 @@ again:
 			ret = -EINTR;
 			break;
 		}
-		net_poll();
+
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			net_poll();
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			/* do we really need it? is_timeout() can do this work for us. */
+			poller_call();
+		}
 
 		if (is_timeout(nfs_timer_start, NFS_TIMEOUT)) {
 			tries++;
@@ -1324,6 +1360,48 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
 	free(str);
 }
 
+static void nfs_cb(uint16_t ev, struct pico_socket *sock)
+{
+	struct nfs_priv *npriv = sock->priv;
+	char *pkt = npriv->pkt;
+	int len;
+	union pico_address ep;
+	uint16_t remote_port;
+
+	if (ev == PICO_SOCK_EV_ERR) {
+		printf("              >>>>>> PICO_SOCK_EV_ERR <<<<<<< \n");
+		return;
+	}
+
+	/* FIXME: 2000 */
+	len = pico_socket_recvfrom(sock, pkt, 2000, &ep, &remote_port);
+
+	nfs_state = STATE_DONE;
+	nfs_packet = pkt;
+	nfs_len = len;
+}
+
+static struct pico_socket *nfs_socket_open(uint16_t localport)
+{
+	struct pico_socket *sock;
+	union pico_address local_address;
+
+	sock = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_UDP, nfs_cb);
+	if (!sock)
+		return NULL;
+
+	localport = short_be(localport);
+
+	/* FIXME: use local_address == PICO_IPV4_INADDR_ANY */
+	memset(&local_address, 0, sizeof(union pico_address));
+	if (pico_socket_bind(sock, &local_address, &localport) < 0) {
+		pico_socket_close(sock);
+		return NULL;
+	}
+
+	return sock;
+}
+
 static int nfs_probe(struct device_d *dev)
 {
 	struct fs_device_d *fsdev = dev_to_fs_device(dev);
@@ -1346,19 +1424,38 @@ static int nfs_probe(struct device_d *dev)
 
 	npriv->path = xstrdup(path + 1);
 
-	npriv->server = resolv(tmp);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		npriv->server = resolv(tmp);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: check corectness */
+		npriv->remote_address.ip4.addr = resolv(tmp);
+	}
 
 	debug("nfs: server: %s path: %s\n", tmp, npriv->path);
 
-	npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
-	if (IS_ERR(npriv->con)) {
-		ret = PTR_ERR(npriv->con);
-		goto err1;
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
+		if (IS_ERR(npriv->con)) {
+			ret = PTR_ERR(npriv->con);
+			goto err1;
+		}
+
+		/* Need a priviliged source port */
+		net_udp_bind(npriv->con, 1000);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: 2048 */
+		npriv->pkt = xzalloc(2048);
+
+		/* Need a priviliged source port */
+		npriv->sock = nfs_socket_open(1000);
+		if (!npriv->sock) {
+			ret = -1;
+			goto err1;
+		}
+
+		npriv->sock->priv = npriv;
 	}
 
-	/* Need a priviliged source port */
-	net_udp_bind(npriv->con, 1000);
-
 	parseopt_hu(fsdev->options, "mountport", &npriv->mount_port);
 	if (!npriv->mount_port) {
 		ret = rpc_lookup_req(npriv, PROG_MOUNT, 3);
@@ -1381,6 +1478,11 @@ static int nfs_probe(struct device_d *dev)
 	}
 	debug("nfs port: %d\n", npriv->nfs_port);
 
+	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		npriv->mount_port = hton16(npriv->mount_port);
+		npriv->nfs_port = hton16(npriv->nfs_port);
+	}
+
 	ret = nfs_mount_req(npriv);
 	if (ret) {
 		printf("mounting failed with %d\n", ret);
@@ -1394,8 +1496,16 @@ static int nfs_probe(struct device_d *dev)
 	return 0;
 
 err2:
-	net_unregister(npriv->con);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_unregister(npriv->con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pico_socket_close(npriv->sock);
+	}
+
 err1:
+	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		free(npriv->pkt);
+	}
 	free(npriv->path);
 err:
 	free(tmp);
@@ -1410,7 +1520,13 @@ static void nfs_remove(struct device_d *dev)
 
 	nfs_umount_req(npriv);
 
-	net_unregister(npriv->con);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_unregister(npriv->con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pico_socket_close(npriv->sock);
+		free(npriv->pkt);
+	}
+
 	free(npriv->path);
 	free(npriv);
 }
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 05/12] WIP: fs/tftp.c: convert to picotcp
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (3 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 04/12] WIP: fs/nfs.c: convert to picotcp Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 06/12] WIP: net/dns: " Antony Pavlov
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 fs/tftp.c | 199 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 175 insertions(+), 24 deletions(-)

diff --git a/fs/tftp.c b/fs/tftp.c
index 0de215e..9d003b4 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -33,6 +33,10 @@
 #include <kfifo.h>
 #include <linux/sizes.h>
 
+#include <pico_socket.h>
+#include <pico_ipv4.h>
+#include <poller.h>
+
 #define TFTP_PORT	69	/* Well known TFTP port number */
 
 /* Seconds to wait before remote server is allowed to resend a lost packet */
@@ -84,10 +88,17 @@ struct file_priv {
 	void *buf;
 	int blocksize;
 	int block_requested;
+
+	struct pico_socket *sock;
+	union pico_address remote_address;
+	uint16_t remote_port;
+	uint8_t *pkt;
 };
 
 struct tftp_priv {
 	IPaddr_t server;
+
+	union pico_address pserver;
 };
 
 static int tftp_create(struct device_d *dev, const char *pathname, mode_t mode)
@@ -120,9 +131,15 @@ static int tftp_send(struct file_priv *priv)
 	unsigned char *xp;
 	int len = 0;
 	uint16_t *s;
-	unsigned char *pkt = net_udp_get_payload(priv->tftp_con);
+	uint8_t *pkt;
 	int ret;
 
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		pkt = net_udp_get_payload(priv->tftp_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pkt = priv->pkt;
+	}
+
 	debug("%s: state %d\n", __func__, priv->state);
 
 	switch (priv->state) {
@@ -169,7 +186,13 @@ static int tftp_send(struct file_priv *priv)
 		break;
 	}
 
-	ret = net_udp_send(priv->tftp_con, len);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		ret = net_udp_send(priv->tftp_con, len);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: convert PICOTCP error code to barebox error code */
+		ret = pico_socket_sendto(priv->sock, priv->pkt, len,
+			&priv->remote_address, priv->remote_port);
+	}
 
 	return ret;
 }
@@ -177,9 +200,15 @@ static int tftp_send(struct file_priv *priv)
 static int tftp_send_write(struct file_priv *priv, void *buf, int len)
 {
 	uint16_t *s;
-	unsigned char *pkt = net_udp_get_payload(priv->tftp_con);
+	uint8_t *pkt;
 	int ret;
 
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		pkt = net_udp_get_payload(priv->tftp_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pkt = priv->pkt;
+	}
+
 	s = (uint16_t *)pkt;
 	*s++ = htons(TFTP_DATA);
 	*s++ = htons(priv->block);
@@ -188,7 +217,14 @@ static int tftp_send_write(struct file_priv *priv, void *buf, int len)
 		priv->state = STATE_LAST;
 	len += 4;
 
-	ret = net_udp_send(priv->tftp_con, len);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		ret = net_udp_send(priv->tftp_con, len);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: convert PICOTCP error code to barebox error code */
+		ret = pico_socket_sendto(priv->sock, priv->pkt, len,
+			&priv->remote_address, priv->remote_port);
+	}
+
 	priv->last_block = priv->block;
 	priv->state = STATE_WAITACK;
 
@@ -216,7 +252,12 @@ static int tftp_poll(struct file_priv *priv)
 		return -ETIMEDOUT;
 	}
 
-	net_poll();
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_poll();
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* despite of is_timeout() can call poller_call() by itself ... */
+		poller_call();
+	}
 
 	return 0;
 }
@@ -293,14 +334,24 @@ static void tftp_recv(struct file_priv *priv,
 			priv->state = STATE_DONE;
 			break;
 		}
-		priv->tftp_con->udp->uh_dport = uh_sport;
+
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			priv->tftp_con->udp->uh_dport = uh_sport;
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			priv->remote_port = uh_sport;
+		}
+
 		priv->state = STATE_WDATA;
 		break;
 
 	case TFTP_OACK:
 		tftp_parse_oack(priv, pkt, len);
-		priv->server_port = ntohs(uh_sport);
-		priv->tftp_con->udp->uh_dport = uh_sport;
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			priv->server_port = ntohs(uh_sport);
+			priv->tftp_con->udp->uh_dport = uh_sport;
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			priv->remote_port = uh_sport;
+		}
 
 		if (priv->push) {
 			/* send first block */
@@ -321,8 +372,12 @@ static void tftp_recv(struct file_priv *priv,
 		if (priv->state == STATE_RRQ || priv->state == STATE_OACK) {
 			/* first block received */
 			priv->state = STATE_RDATA;
-			priv->tftp_con->udp->uh_dport = uh_sport;
-			priv->server_port = ntohs(uh_sport);
+			if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+				priv->tftp_con->udp->uh_dport = uh_sport;
+				priv->server_port = ntohs(uh_sport);
+			} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+				priv->remote_port = uh_sport;
+			}
 			priv->last_block = 0;
 
 			if (priv->block != 1) {	/* Assertion */
@@ -381,6 +436,53 @@ static void tftp_handler(void *ctx, char *packet, unsigned len)
 	tftp_recv(priv, pkt, net_eth_to_udplen(packet), udp->uh_sport);
 }
 
+static void tftp_cb(uint16_t ev, struct pico_socket *sock)
+{
+	struct file_priv *priv = sock->priv;
+
+	union pico_address ep;
+	uint16_t remote_port;
+	uint8_t *pkt = priv->pkt;
+	int len;
+
+	if (ev == PICO_SOCK_EV_ERR) {
+		printf("              >>>>>> PICO_SOCK_EV_ERR <<<<<<< \n");
+		return;
+	}
+
+	/*
+	 * we have to receive:
+	 *     opcode (2 bytes)
+	 *     block# (2 bytes)
+	 *     data (blocksize bytes)
+	 */
+	len = pico_socket_recvfrom(sock, pkt, priv->blocksize + 4,
+					&ep, &remote_port);
+
+	tftp_recv(priv, pkt, len, remote_port);
+}
+
+static struct pico_socket *tftp_socket_open(uint16_t localport)
+{
+	struct pico_socket *sock;
+	union pico_address local_address;
+
+	sock = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_UDP, tftp_cb);
+	if (!sock)
+		return NULL;
+
+	localport = short_be(localport);
+
+	/* FIXME: use local_address == PICO_IPV4_INADDR_ANY */
+	memset(&local_address, 0, sizeof(union pico_address));
+	if (pico_socket_bind(sock, &local_address, &localport) < 0) {
+		pico_socket_close(sock);
+		return NULL;
+	}
+
+	return sock;
+}
+
 static struct file_priv *tftp_do_open(struct device_d *dev,
 		int accmode, const char *filename)
 {
@@ -426,17 +528,39 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
 		goto out;
 	}
 
-	priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
-			priv);
-	if (IS_ERR(priv->tftp_con)) {
-		ret = PTR_ERR(priv->tftp_con);
-		goto out1;
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		priv->tftp_con = net_udp_new(tpriv->server, TFTP_PORT, tftp_handler,
+				priv);
+		if (IS_ERR(priv->tftp_con)) {
+			ret = PTR_ERR(priv->tftp_con);
+			goto out1;
+		}
+
+		ret = tftp_send(priv);
+		if (ret)
+			goto out2;
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		priv->sock = tftp_socket_open(0);
+		if (!priv->sock) {
+			ret = -1;
+			goto out1;
+		}
+
+		priv->sock->priv = priv;
+
+		/* FIXME: add free */
+		priv->pkt = xzalloc(2048);
+		priv->remote_address = tpriv->pserver;
+		priv->remote_port = short_be(TFTP_PORT);
+
+		/* FIXME: convert PICOTCP error code to barebox error code */
+		ret = tftp_send(priv);
+		if (ret == -1)
+			goto out2;
+
+		poller_call();
 	}
 
-	ret = tftp_send(priv);
-	if (ret)
-		goto out2;
-
 	tftp_timer_reset(priv);
 	while (priv->state != STATE_RDATA &&
 			priv->state != STATE_DONE &&
@@ -457,7 +581,11 @@ static struct file_priv *tftp_do_open(struct device_d *dev,
 
 	return priv;
 out2:
-	net_unregister(priv->tftp_con);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_unregister(priv->tftp_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pico_socket_close(priv->sock);
+	}
 out1:
 	kfifo_free(priv->fifo);
 out:
@@ -503,14 +631,32 @@ static int tftp_do_close(struct file_priv *priv)
 	}
 
 	if (!priv->push && priv->state != STATE_DONE) {
-		uint16_t *pkt = net_udp_get_payload(priv->tftp_con);
+		uint16_t *pkt;
+
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			pkt = net_udp_get_payload(priv->tftp_con);
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			pkt = (uint16_t *)priv->pkt;
+		}
+
 		*pkt++ = htons(TFTP_ERROR);
 		*pkt++ = 0;
 		*pkt++ = 0;
-		net_udp_send(priv->tftp_con, 6);
+
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			net_udp_send(priv->tftp_con, 6);
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			pico_socket_sendto(priv->sock, priv->pkt, 6,
+				&priv->remote_address, priv->remote_port);
+		}
+	}
+
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_unregister(priv->tftp_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		pico_socket_close(priv->sock);
 	}
 
-	net_unregister(priv->tftp_con);
 	kfifo_free(priv->fifo);
 	free(priv->buf);
 	free(priv);
@@ -630,7 +776,12 @@ static int tftp_probe(struct device_d *dev)
 
 	dev->priv = priv;
 
-	priv->server = resolv(fsdev->backingstore);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		priv->server = resolv(fsdev->backingstore);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		/* FIXME: check corectness */
+		priv->pserver.ip4.addr = resolv(fsdev->backingstore);
+	}
 
 	return 0;
 }
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 06/12] WIP: net/dns: convert to picotcp
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (4 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 05/12] WIP: fs/tftp.c: " Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 07/12] net: picotcp: add test_picotcp command Antony Pavlov
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/dns.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 94 insertions(+), 7 deletions(-)

diff --git a/net/dns.c b/net/dns.c
index 0e16ea2..2a35e3b 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -29,6 +29,10 @@
 #include <environment.h>
 #include <linux/err.h>
 
+#include <pico_socket.h>
+#include <pico_ipv4.h>
+#include <poller.h>
+
 #define DNS_PORT 53
 
 /* http://en.wikipedia.org/wiki/List_of_DNS_record_types */
@@ -59,15 +63,24 @@ static uint64_t dns_timer_start;
 static int dns_state;
 static IPaddr_t dns_ip;
 
+static struct pico_socket *sock;
+static uint8_t *pkt;
+
 static int dns_send(char *name)
 {
 	int ret;
 	struct header *header;
 	enum dns_query_type qtype = DNS_A_RECORD;
-	unsigned char *packet = net_udp_get_payload(dns_con);
+	unsigned char *packet;
 	unsigned char *p, *s, *fullname, *dotptr;
 	const unsigned char *domain;
 
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		packet = net_udp_get_payload(dns_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		packet = pkt;
+	}
+
 	/* Prepare DNS packet header */
 	header           = (struct header *)packet;
 	header->tid      = 1;
@@ -109,7 +122,16 @@ static int dns_send(char *name)
 	*p++ = 0;
 	*p++ = 1;				/* Class: inet, 0x0001 */
 
-	ret = net_udp_send(dns_con, p - packet);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		ret = net_udp_send(dns_con, p - packet);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		uint16_t remote_port;
+
+		remote_port = htons(DNS_PORT);
+		pico_socket_send(sock, pkt, p - packet);
+		/* FIXME */
+		ret = 0;
+	}
 
 	free(fullname);
 
@@ -199,6 +221,44 @@ static void dns_handler(void *ctx, char *packet, unsigned len)
 		net_eth_to_udplen(packet));
 }
 
+static void dns_cb(uint16_t ev, struct pico_socket *sock)
+{
+	union pico_address ep;
+	uint16_t remote_port;
+	int len;
+
+	if (ev == PICO_SOCK_EV_ERR) {
+		printf("              >>>>>> PICO_SOCK_EV_ERR <<<<<<< \n");
+		return;
+	}
+
+	/* FIXME: 1500 */
+	len = pico_socket_recvfrom(sock, pkt, 1500, &ep, &remote_port);
+
+	dns_recv((struct header *)pkt, len);
+}
+
+static struct pico_socket *dns_socket_open(uint16_t localport)
+{
+	struct pico_socket *sock;
+	union pico_address local_address;
+
+	sock = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_UDP, dns_cb);
+	if (!sock)
+		return NULL;
+
+	localport = htons(localport);
+
+	/* FIXME: use local_address == PICO_IPV4_INADDR_ANY */
+	memset(&local_address, 0, sizeof(union pico_address));
+	if (pico_socket_bind(sock, &local_address, &localport) < 0) {
+		pico_socket_close(sock);
+		return NULL;
+	}
+
+	return sock;
+}
+
 IPaddr_t resolv(char *host)
 {
 	IPaddr_t ip;
@@ -223,9 +283,26 @@ IPaddr_t resolv(char *host)
 
 	debug("resolving host %s via nameserver %s\n", host, ip_to_string(ip));
 
-	dns_con = net_udp_new(ip, DNS_PORT, dns_handler, NULL);
-	if (IS_ERR(dns_con))
-		return PTR_ERR(dns_con);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		dns_con = net_udp_new(ip, DNS_PORT, dns_handler, NULL);
+		if (IS_ERR(dns_con))
+			return PTR_ERR(dns_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		static union pico_address pico_dns_ip;
+
+		pico_string_to_ipv4(ns, &pico_dns_ip.ip4.addr);
+
+		sock = dns_socket_open(0);
+		if (!sock)
+			return 0;
+
+		if (pico_socket_connect(sock, &pico_dns_ip, htons(DNS_PORT)) < 0)
+			return 0;
+
+		/* FIXME: 2048 */
+		pkt = xzalloc(2048);
+	}
+
 	dns_timer_start = get_time_ns();
 	dns_send(host);
 
@@ -233,7 +310,13 @@ IPaddr_t resolv(char *host)
 		if (ctrlc()) {
 			break;
 		}
-		net_poll();
+
+		if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+			net_poll();
+		} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+			poller_call();
+		}
+
 		if (is_timeout(dns_timer_start, SECOND)) {
 			dns_timer_start = get_time_ns();
 			printf("T ");
@@ -241,7 +324,11 @@ IPaddr_t resolv(char *host)
 		}
 	}
 
-	net_unregister(dns_con);
+	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
+		net_unregister(dns_con);
+	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
+		free(pkt);
+	}
 
 	return dns_ip;
 }
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 07/12] net: picotcp: add test_picotcp command
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (5 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 06/12] WIP: net/dns: " Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 08/12] net: picotcp: add ifconfig command Antony Pavlov
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

See original test_ipv4() from picotcp.git/test/unit/unit_ipv4.c.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/Makefile            |  2 ++
 net/picotcp/Kconfig     |  7 ++++
 net/picotcp_test_ipv4.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index 7a4597d..bfe74fb 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -10,3 +10,5 @@ obj-$(CONFIG_NET_IFUP)	+= ifup.o
 
 obj-$(CONFIG_NET_PICOTCP) += picotcp/
 obj-$(CONFIG_NET_PICOTCP) += picotcp.o
+
+obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
index 3882984..17b8293 100644
--- a/net/picotcp/Kconfig
+++ b/net/picotcp/Kconfig
@@ -31,4 +31,11 @@ config NET_PICO_BIGENDIAN
 	bool
 	prompt "bigendian picotcp"
 
+comment "Commands"
+
+config CMD_PICOTCP_TEST_IPV4
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "test_picotcp command"
+
 endif # NET_PICOTCP
diff --git a/net/picotcp_test_ipv4.c b/net/picotcp_test_ipv4.c
new file mode 100644
index 0000000..314d21c
--- /dev/null
+++ b/net/picotcp_test_ipv4.c
@@ -0,0 +1,96 @@
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_dev_null.h>
+
+#define fail_if(a, msg) \
+	if (a) { \
+		printf("%s\n", msg); \
+		return; \
+	}
+
+#define fail_unless(a, msg) fail_if(!(a), msg)
+
+static void do_test_ipv4(void)
+{
+	#define IP_TST_SIZ 256
+	int i;
+
+	struct pico_device *dev[IP_TST_SIZ];
+	char devname[8];
+	struct pico_ip4 a[IP_TST_SIZ], d[IP_TST_SIZ], *source[IP_TST_SIZ], nm16, nm32, gw[IP_TST_SIZ], r[IP_TST_SIZ], ret;
+	struct pico_ipv4_link *l[IP_TST_SIZ];
+
+	char ipstr[] = "192.168.1.1";
+	struct pico_ip4 ipaddr;
+
+	struct pico_frame *f_NULL = NULL;
+	struct pico_ip4 *dst_NULL = NULL;
+
+	nm16.addr = long_be(0xFFFF0000);
+	nm32.addr = long_be(0xFFFFFFFF);
+
+	/*link_add*/
+	for (i = 0; i < IP_TST_SIZ; i++) {
+		snprintf(devname, 8, "nul%d", i);
+		dev[i] = pico_null_create(devname);
+		a[i].addr = long_be(0x0a000001 + (i << 16));
+		d[i].addr = long_be(0x0a000002 + (i << 16));
+		fail_if(pico_ipv4_link_add(dev[i], a[i], nm16) != 0, "Error adding link");
+	}
+	/*link_find + link_get + route_add*/
+	for (i = 0; i < IP_TST_SIZ; i++) {
+		gw[i].addr = long_be(0x0a0000f0 + (i << 16));
+		r[i].addr = long_be(0x0c00001 + (i << 16));
+		fail_unless(pico_ipv4_link_find(&a[i]) == dev[i], "Error finding link");
+		l[i] = pico_ipv4_link_get(&a[i]);
+		fail_if(l[i] == NULL, "Error getting link");
+		fail_if(pico_ipv4_route_add(r[i], nm32, gw[i], 1, l[i]) != 0, "Error adding route");
+		fail_if(pico_ipv4_route_add(d[i], nm32, gw[i], 1, l[i]) != 0, "Error adding route");
+	}
+	/*get_gateway + source_find*/
+	for (i = 0; i < IP_TST_SIZ; i++) {
+		ret = pico_ipv4_route_get_gateway(&r[i]);
+		fail_if(ret.addr != gw[i].addr, "Error get gateway: returned wrong route");
+		source[i] = pico_ipv4_source_find(&d[i]);
+		fail_if(source[i]->addr != a[i].addr, "Error find source: returned wrong route");
+	}
+	/*route_del + link_del*/
+	for (i = 0; i < IP_TST_SIZ; i++) {
+		fail_if(pico_ipv4_route_del(r[i], nm32, 1) != 0, "Error deleting route");
+		fail_if(pico_ipv4_link_del(dev[i], a[i]) != 0, "Error deleting link");
+	}
+	/*string_to_ipv4 + ipv4_to_string*/
+	pico_string_to_ipv4(ipstr, &(ipaddr.addr));
+	fail_if(ipaddr.addr != long_be(0xc0a80101), "Error string to ipv4");
+	memset(ipstr, 0, 12);
+	pico_ipv4_to_string(ipstr, ipaddr.addr);
+	fail_if(strncmp(ipstr, "192.168.1.1", 11) != 0, "Error ipv4 to string");
+
+	/*valid_netmask*/
+	fail_if(pico_ipv4_valid_netmask(long_be(nm32.addr)) != 32, "Error checking netmask");
+
+	/*is_unicast*/
+	fail_if((pico_ipv4_is_unicast(long_be(0xc0a80101))) != 1, "Error checking unicast");
+	fail_if((pico_ipv4_is_unicast(long_be(0xe0000001))) != 0, "Error checking unicast");
+
+	/*rebound*/
+	fail_if(pico_ipv4_rebound(f_NULL) != -1, "Error rebound frame");
+
+	/*frame_push*/
+	fail_if(pico_ipv4_frame_push(f_NULL, dst_NULL, PICO_PROTO_TCP) != -1, "Error push frame");
+}
+
+static int do_test_picotcp(int argc, char *argv[])
+{
+	do_test_ipv4();
+
+	return 0;
+}
+
+BAREBOX_CMD_START(test_picotcp)
+	.cmd		= do_test_picotcp,
+BAREBOX_CMD_END
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 08/12] net: picotcp: add ifconfig command
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (6 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 07/12] net: picotcp: add test_picotcp command Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 09/12] net: picotcp: add ping command Antony Pavlov
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/Makefile           |   1 +
 net/picotcp/Kconfig    |   5 +++
 net/picotcp_ifconfig.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 122 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index bfe74fb..d5b133b 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp/
 obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
+obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
index 17b8293..9a2d628 100644
--- a/net/picotcp/Kconfig
+++ b/net/picotcp/Kconfig
@@ -38,4 +38,9 @@ config CMD_PICOTCP_TEST_IPV4
 	depends on NET_PICO_SUPPORT_IPV4
 	prompt "test_picotcp command"
 
+config CMD_PICOTCP_IFCONFIG
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "ifconfig command"
+
 endif # NET_PICOTCP
diff --git a/net/picotcp_ifconfig.c b/net/picotcp_ifconfig.c
new file mode 100644
index 0000000..1d4e89b
--- /dev/null
+++ b/net/picotcp_ifconfig.c
@@ -0,0 +1,116 @@
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_dev_null.h>
+#include <pico_icmp4.h>
+#include <pico_tree.h>
+
+extern struct pico_tree Device_tree;
+extern struct pico_tree Tree_dev_link;
+
+static void printf_iface(struct pico_device *dev)
+{
+	struct pico_ipv4_link *link;
+	struct pico_tree_node *index;
+
+	printf("%-10s", dev->name);
+
+	if (dev->eth) {
+		struct pico_ethdev *eth = dev->eth;
+
+		printf("Link encap:Ethernet  HWaddr ");
+		printf("%02x:%02x:%02x:%02x:%02x:%02x",
+			eth->mac.addr[0], eth->mac.addr[1],
+			eth->mac.addr[2], eth->mac.addr[3],
+			eth->mac.addr[4], eth->mac.addr[5]);
+	}
+	printf("\n");
+
+	pico_tree_foreach(index, &Tree_dev_link) {
+		link = index->keyValue;
+		if (dev == link->dev) {
+			char ipstr[16];
+			pico_ipv4_to_string(ipstr, link->address.addr);
+			printf("          inet addr:%s", ipstr);
+			pico_ipv4_to_string(ipstr, link->netmask.addr);
+			printf(" Mask:%s\n", ipstr);
+		}
+	}
+	printf("\n");
+}
+
+static int do_ifconfig(int argc, char *argv[])
+{
+	struct pico_device *picodev;
+	struct pico_ip4 ipaddr, nm;
+	int ret;
+
+	if (argc == 1) {
+		struct pico_tree_node *index;
+
+		pico_tree_foreach(index, &Device_tree) {
+			printf_iface(index->keyValue);
+		}
+
+		return 0;
+	}
+
+	picodev = pico_get_device(argv[1]);
+	if (!picodev) {
+		struct pico_device *dev;
+		struct pico_tree_node *index;
+
+		perror("wrong device name");
+
+		printf("available interfaces:\n");
+
+		pico_tree_foreach(index, &Device_tree) {
+			dev = index->keyValue;
+			printf("%s\n", dev->name);
+		}
+
+		return 1;
+	}
+
+	if (argc == 2) {
+		struct pico_tree_node *index;
+
+		pico_tree_foreach(index, &Device_tree) {
+			struct pico_device *dev = index->keyValue;
+
+			if (!strcmp(dev->name, argv[1])) {
+				printf_iface(dev);
+			}
+		}
+
+		return 0;
+	}
+
+	if (argc < 4) {
+		perror("ifconfig");
+		return 1;
+	}
+
+	ret = pico_string_to_ipv4(argv[2], &(ipaddr.addr));
+	if (ret) {
+		perror("wrong ipaddr");
+		return 1;
+	}
+
+	ret = pico_string_to_ipv4(argv[3], &(nm.addr));
+	if (ret) {
+		perror("wrong netmask");
+		return 1;
+	}
+
+	pico_ipv4_link_add(picodev, ipaddr, nm);
+
+	return 0;
+}
+
+BAREBOX_CMD_START(ifconfig)
+	.cmd		= do_ifconfig,
+BAREBOX_CMD_END
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 09/12] net: picotcp: add ping command
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (7 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 08/12] net: picotcp: add ifconfig command Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 10/12] net: picotcp: add route command Antony Pavlov
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/Makefile        |  1 +
 net/picotcp/Kconfig |  5 ++++
 net/picotcp_ping.c  | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index d5b133b..04e347f 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
 obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
+obj-$(CONFIG_CMD_PICOTCP_PING) += picotcp_ping.o
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
index 9a2d628..cb60001 100644
--- a/net/picotcp/Kconfig
+++ b/net/picotcp/Kconfig
@@ -43,4 +43,9 @@ config CMD_PICOTCP_IFCONFIG
 	depends on NET_PICO_SUPPORT_IPV4
 	prompt "ifconfig command"
 
+config CMD_PICOTCP_PING
+	bool
+	depends on NET_PICO_SUPPORT_ICMP4
+	prompt "ping command"
+
 endif # NET_PICOTCP
diff --git a/net/picotcp_ping.c b/net/picotcp_ping.c
new file mode 100644
index 0000000..d4ceb92
--- /dev/null
+++ b/net/picotcp_ping.c
@@ -0,0 +1,85 @@
+#include <command.h>
+#include <common.h>
+#include <complete.h>
+#include <driver.h>
+#include <poller.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_dev_null.h>
+#include <pico_dhcp_client.h>
+#include <pico_icmp4.h>
+
+#define NUM_PING 10
+
+static int ping_done;
+static int ping_code;
+
+/* callback function for receiving ping reply */
+void cb_ping(struct pico_icmp4_stats *s)
+{
+	char host[30];
+	int time_sec = 0;
+	int time_msec = 0;
+
+	/* convert ip address from icmp4_stats structure to string */
+	pico_ipv4_to_string(host, s->dst.addr);
+
+	/* get time information from icmp4_stats structure */
+	time_sec = s->time / 1000;
+	time_msec = s->time % 1000;
+
+	if (s->err == PICO_PING_ERR_REPLIED) {
+		/* print info if no error reported in icmp4_stats structure */
+		printf("%lu bytes from %s: icmp_req=%lu ttl=%lu time=%llu ms\n", \
+			s->size, host, s->seq, s->ttl, s->time);
+		if (s->seq == NUM_PING) {
+			ping_done = 1;
+		}
+	} else {
+		/* else, print error info */
+		printf("PING %lu to %s: Error %d\n", s->seq, host, s->err);
+		ping_done = 1;
+	}
+
+	ping_code = s->err;
+}
+
+static int do_picoping(int argc, char *argv[])
+{
+	int id;
+
+	if (argc < 1) {
+		perror("picoping");
+		return 1;
+	}
+
+	id = pico_icmp4_ping(argv[1], NUM_PING, 1000, 5000, 48, cb_ping);
+
+	if (id == -1) {
+		return -EIO;
+	}
+
+	ping_done = 0;
+	ping_code = PICO_PING_ERR_PENDING;
+
+	while (!ping_done) {
+		if (ctrlc()) {
+			break;
+		}
+		get_time_ns();
+		poller_call();
+	}
+
+	pico_icmp4_ping_abort(id);
+
+	if (ping_code != PICO_PING_ERR_REPLIED) {
+		return -EIO;
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(picoping)
+	.cmd		= do_picoping,
+BAREBOX_CMD_END
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 10/12] net: picotcp: add route command
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (8 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 09/12] net: picotcp: add ping command Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 11/12] sandbox_defconfig: switch to picotcp Antony Pavlov
  2015-07-15 20:13 ` [RFC 12/12] WIP: sandbox_defconfig: enable network testing-related stuff Antony Pavlov
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 net/Makefile        |  1 +
 net/picotcp/Kconfig |  5 +++++
 net/picotcp_route.c | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index 04e347f..6261454 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -14,3 +14,4 @@ obj-$(CONFIG_NET_PICOTCP) += picotcp.o
 obj-$(CONFIG_CMD_PICOTCP_TEST_IPV4) += picotcp_test_ipv4.o
 obj-$(CONFIG_CMD_PICOTCP_IFCONFIG) += picotcp_ifconfig.o
 obj-$(CONFIG_CMD_PICOTCP_PING) += picotcp_ping.o
+obj-$(CONFIG_CMD_PICOTCP_ROUTE) += picotcp_route.o
diff --git a/net/picotcp/Kconfig b/net/picotcp/Kconfig
index cb60001..2cd04d2 100644
--- a/net/picotcp/Kconfig
+++ b/net/picotcp/Kconfig
@@ -48,4 +48,9 @@ config CMD_PICOTCP_PING
 	depends on NET_PICO_SUPPORT_ICMP4
 	prompt "ping command"
 
+config CMD_PICOTCP_ROUTE
+	bool
+	depends on NET_PICO_SUPPORT_IPV4
+	prompt "route command"
+
 endif # NET_PICOTCP
diff --git a/net/picotcp_route.c b/net/picotcp_route.c
new file mode 100644
index 0000000..a2b1453
--- /dev/null
+++ b/net/picotcp_route.c
@@ -0,0 +1,37 @@
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <poller.h>
+
+#include <pico_stack.h>
+#include <pico_ipv4.h>
+#include <pico_icmp4.h>
+
+static int do_route(int argc, char *argv[])
+{
+	struct pico_ipv4_route *r;
+	struct pico_tree_node *index;
+
+	printf("picotcp IPv4 routing table\n");
+	printf("Destination     Gateway         Genmask         Metric Iface\n");
+
+	pico_tree_foreach(index, &Routes) {
+		char ipstr[32];
+
+		r = index->keyValue;
+
+		pico_ipv4_to_string(ipstr, r->dest.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->gateway.addr);
+		printf("%-16s", ipstr);
+		pico_ipv4_to_string(ipstr, r->netmask.addr);
+		printf("%-16s", ipstr);
+		printf("%-7d%s\n", r->metric, r->link->dev->name);
+	}
+
+	return 0;
+}
+
+BAREBOX_CMD_START(route)
+	.cmd		= do_route,
+BAREBOX_CMD_END
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 11/12] sandbox_defconfig: switch to picotcp
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (9 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 10/12] net: picotcp: add route command Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  2015-07-15 20:13 ` [RFC 12/12] WIP: sandbox_defconfig: enable network testing-related stuff Antony Pavlov
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Picotcp sandbox barebox howto
=============================

Compile sandbox barebox:

  $ cd barebox.git
  $ unset ARCH
  $ unset CROSS_COMPILE
  $ make sandbox_defconfig
  ...
  $ make

Run barebox:

  $ su
  # ./barebox

Testing ping
------------

While sandbox barebox is running setup a IP-address
for your host 'barebox' network interface, e.g.:

  # ifconfig barebox 192.168.1.1

Next, in sandbox barebox console setup network interface
and try to ping host:

  barebox:/ ifconfig eth 192.168.1.2 255.255.255.0
  Assigned ipv4 192.168.1.2 to device eth
  barebox:/ picoping 192.168.1.1
  48 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=1 ms
  ...
  48 bytes from 192.168.1.1: icmp_req=10 ttl=64 time=0 ms

Testing domain name resolving
-----------------------------

Install simple maradns name server on the host.

Edit /etc/maradns/mararc config file, add these lines:

  csv2 = {}
  csv2["example.com."] = "db.example.com"

  bind_address = "192.168.1.1"

Edit /etc/maradns/db.example.com, add these lines:

  example.com. 192.168.1.1 ~
  www.example.com. 192.168.1.1 ~
  barebox.example.com. 192.168.1.2 ~

Run sandbox barebox and setup the www.example.com IP-address
for your host 'barebox' network interface, e.g.:

  # ifconfig barebox 192.168.1.1

Restart maradns:

  $ /etc/init.d/maradns restart

Check name resolution:

  barebox@barebox sandbox:/ ifconfig eth 192.168.1.2 255.255.255.0
  Assigned ipv4 192.168.1.2 to device eth
  barebox@barebox sandbox:/ net.nameserver=192.168.1.1
  barebox@barebox sandbox:/ host barebox.example.com
  barebox.example.com is at 192.168.1.2
  barebox@barebox sandbox:/ host www.example.com
  www.example.com is at 192.168.1.1

The same checks for barebox legacy network stack:

  barebox@barebox sandbox:/ eth0.ipaddr=192.168.1.2
  barebox@barebox sandbox:/ eth0.serverip=192.168.1.1
  barebox@barebox sandbox:/ net.domainname=example.com
  barebox@barebox sandbox:/ net.nameserver=192.168.1.1
  barebox@barebox sandbox:/ host barebox.example.com
  warning: No MAC address set. Using random address 9a:a1:86:31:05:1e
  barebox.example.com is at 192.168.1.2
  barebox@barebox sandbox:/ host www.example.com
  www.example.com is at 192.168.1.1

Testing dhcp (ad memorandum)
----------------------------

Configure your host dhcp server, e.g. add this
to your /etc/dhcp/dhcpd.conf:

  subnet 192.168.1.0 netmask 255.255.255.0 {
    range dynamic-bootp 192.168.1.26 192.168.1.29;
    option routers 192.168.1.1;
    option broadcast-address 192.168.1.255;
    default-lease-time 600;
    max-lease-time 7200;
  }

While sandbox barebox is running setup a IP-address
for your host 'barebox' network interface and restart
your host dhcp server, e.g.:

  # ifconfig barebox 192.168.1.1
  # /etc/init.d/isc-dhcp-server restart

Next, in your sandbox barebox console run 'dhclient':

  barebox:/ dhclient eth
  Assigned ipv4 0.0.0.0 to device eth
  Assigned ipv4 192.168.1.26 to device eth
  DHCP client: renewal time (T1) 300
  DHCP client: rebinding time (T2) 525
  DHCP client: lease time 496
  DHCP client: IP assigned by the server: 192.168.1.26

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/sandbox/configs/sandbox_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index ec045f7..909969a 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -31,6 +31,13 @@ CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OF_DISPLAY_TIMINGS=y
 CONFIG_CMD_OFTREE=y
 CONFIG_NET=y
+CONFIG_NET_PICOTCP=y
+CONFIG_NET_NFS=y
+CONFIG_NET_RESOLV=y
+CONFIG_CMD_PICOTCP_TEST_IPV4=y
+CONFIG_CMD_PICOTCP_IFCONFIG=y
+CONFIG_CMD_PICOTCP_PING=y
+CONFIG_CMD_PICOTCP_ROUTE=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_NET_TAP=y
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC 12/12] WIP: sandbox_defconfig: enable network testing-related stuff
  2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
                   ` (10 preceding siblings ...)
  2015-07-15 20:13 ` [RFC 11/12] sandbox_defconfig: switch to picotcp Antony Pavlov
@ 2015-07-15 20:13 ` Antony Pavlov
  11 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-15 20:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 arch/sandbox/configs/sandbox_defconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index 909969a..1c42721 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -1,3 +1,4 @@
+CONFIG_MALLOC_SIZE=0x4000000
 CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
@@ -16,6 +17,7 @@ CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_MAGICVAR=y
 CONFIG_CMD_MAGICVAR_HELP=y
 CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_SHA1SUM=y
 CONFIG_CMD_SLEEP=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
@@ -30,6 +32,7 @@ CONFIG_CMD_OF_NODE=y
 CONFIG_CMD_OF_PROPERTY=y
 CONFIG_CMD_OF_DISPLAY_TIMINGS=y
 CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
 CONFIG_NET=y
 CONFIG_NET_PICOTCP=y
 CONFIG_NET_NFS=y
@@ -45,3 +48,5 @@ CONFIG_DRIVER_NET_TAP=y
 # CONFIG_PINCTRL is not set
 CONFIG_FS_CRAMFS=y
 CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
+CONFIG_DIGEST_SHA1_GENERIC=y
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC 04/12] WIP: fs/nfs.c: convert to picotcp
  2015-07-15 20:13 ` [RFC 04/12] WIP: fs/nfs.c: convert to picotcp Antony Pavlov
@ 2015-07-16 19:51   ` Sascha Hauer
  2015-07-17  7:18     ` Antony Pavlov
  0 siblings, 1 reply; 15+ messages in thread
From: Sascha Hauer @ 2015-07-16 19:51 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

Hi Antony,

On Wed, Jul 15, 2015 at 11:13:42PM +0300, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  fs/nfs.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 133 insertions(+), 17 deletions(-)
> 
> @@ -1346,19 +1424,38 @@ static int nfs_probe(struct device_d *dev)
>  
>  	npriv->path = xstrdup(path + 1);
>  
> -	npriv->server = resolv(tmp);
> +	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
> +		npriv->server = resolv(tmp);
> +	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> +		/* FIXME: check corectness */
> +		npriv->remote_address.ip4.addr = resolv(tmp);
> +	}
>  
>  	debug("nfs: server: %s path: %s\n", tmp, npriv->path);
>  
> -	npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
> -	if (IS_ERR(npriv->con)) {
> -		ret = PTR_ERR(npriv->con);
> -		goto err1;
> +	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
> +		npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
> +		if (IS_ERR(npriv->con)) {
> +			ret = PTR_ERR(npriv->con);
> +			goto err1;
> +		}
> +
> +		/* Need a priviliged source port */
> +		net_udp_bind(npriv->con, 1000);
> +	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> +		/* FIXME: 2048 */
> +		npriv->pkt = xzalloc(2048);
> +
> +		/* Need a priviliged source port */
> +		npriv->sock = nfs_socket_open(1000);
> +		if (!npriv->sock) {
> +			ret = -1;
> +			goto err1;
> +		}
> +
> +		npriv->sock->priv = npriv;
>  	}

The different network stacks should be transparent to the users. Instead
of implementing them in tftp/nfs/... I would expect the abstraction in the
current network functions, something like:

struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport,
                rx_handler_f *handler, void *ctx)
{
	struct net_connection *con = net_new(dest, handler, ctx);
	if (IS_ERR(con))
                return con;

	con->proto = IPPROTO_UDP;
	con->udp->uh_dport = htons(dport);
	con->udp->uh_sport = htons(net_udp_new_localport());
	con->ip->protocol = IPPROTO_UDP;

	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
		con->sock = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_UDP, handler);
	}

	return con;
}

static inline int net_udp_bind(struct net_connection *con, int sport)
{
	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
		memset(&local_address, 0, sizeof(union pico_address));
		pico_socket_bind(con->sock, &local_address, &sport);
	} else {
		con->udp->uh_sport = ntohs(sport);
	}

	return 0;
}

int net_udp_send(struct net_connection *con, int len)
{
	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
		return pico_socket_sendto(con->sock, npriv->pkt,
				sizeof(pkt) + datalen * sizeof(uint32_t),
				con->ip->daddr, con->udp->uh_dport);
	}

	con->udp->uh_ulen = htons(len + 8);
	con->udp->uh_sum = 0;

	return net_ip_send(con, sizeof(struct udphdr) + len);
}

The APIs between current barebox implementation and picotcp probably do
not match exactly. Where the APIs don't match we can change the existing
barebox API to what picotcp expects.

With that the remaining pieces like DHCP, netconsole and DNS would work
without additional effort.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC 04/12] WIP: fs/nfs.c: convert to picotcp
  2015-07-16 19:51   ` Sascha Hauer
@ 2015-07-17  7:18     ` Antony Pavlov
  0 siblings, 0 replies; 15+ messages in thread
From: Antony Pavlov @ 2015-07-17  7:18 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Thu, 16 Jul 2015 21:51:50 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> Hi Antony,
> 
> On Wed, Jul 15, 2015 at 11:13:42PM +0300, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> >  fs/nfs.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
> >  1 file changed, 133 insertions(+), 17 deletions(-)
> > 
> > @@ -1346,19 +1424,38 @@ static int nfs_probe(struct device_d *dev)
> >  
> >  	npriv->path = xstrdup(path + 1);
> >  
> > -	npriv->server = resolv(tmp);
> > +	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
> > +		npriv->server = resolv(tmp);
> > +	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> > +		/* FIXME: check corectness */
> > +		npriv->remote_address.ip4.addr = resolv(tmp);
> > +	}
> >  
> >  	debug("nfs: server: %s path: %s\n", tmp, npriv->path);
> >  
> > -	npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
> > -	if (IS_ERR(npriv->con)) {
> > -		ret = PTR_ERR(npriv->con);
> > -		goto err1;
> > +	if (IS_ENABLED(CONFIG_NET_LEGACY)) {
> > +		npriv->con = net_udp_new(npriv->server, 0, nfs_handler, npriv);
> > +		if (IS_ERR(npriv->con)) {
> > +			ret = PTR_ERR(npriv->con);
> > +			goto err1;
> > +		}
> > +
> > +		/* Need a priviliged source port */
> > +		net_udp_bind(npriv->con, 1000);
> > +	} else if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> > +		/* FIXME: 2048 */
> > +		npriv->pkt = xzalloc(2048);
> > +
> > +		/* Need a priviliged source port */
> > +		npriv->sock = nfs_socket_open(1000);
> > +		if (!npriv->sock) {
> > +			ret = -1;
> > +			goto err1;
> > +		}
> > +
> > +		npriv->sock->priv = npriv;
> >  	}
> 
> The different network stacks should be transparent to the users. Instead
> of implementing them in tftp/nfs/... I would expect the abstraction in the
> current network functions, something like:

It's near impossible with current network stack implementation.

We have to drop direct access to net_connection private fields from application code;
e.g. direct access to packet UDP fields in tftp code:

  priv->tftp_con->udp->uh_dport = uh_sport;

My patch series was not intended to change legacy network code in any way.
On the contrary it intentionaly keeps original code "as is".
This approach demonstrates in practice picotcp and legacy network stack differences,
so future work on integration is much more evident.

I can start next round of picotcp integration with removing direct access to net_connection private fields
from application code.


> struct net_connection *net_udp_new(IPaddr_t dest, uint16_t dport,
>                 rx_handler_f *handler, void *ctx)
> {
> 	struct net_connection *con = net_new(dest, handler, ctx);
> 	if (IS_ERR(con))
>                 return con;
> 
> 	con->proto = IPPROTO_UDP;
> 	con->udp->uh_dport = htons(dport);
> 	con->udp->uh_sport = htons(net_udp_new_localport());
> 	con->ip->protocol = IPPROTO_UDP;
> 
> 	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> 		con->sock = pico_socket_open(PICO_PROTO_IPV4, PICO_PROTO_UDP, handler);
> 	}
> 
> 	return con;
> }
> 
> static inline int net_udp_bind(struct net_connection *con, int sport)
> {
> 	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> 		memset(&local_address, 0, sizeof(union pico_address));
> 		pico_socket_bind(con->sock, &local_address, &sport);
> 	} else {
> 		con->udp->uh_sport = ntohs(sport);
> 	}
> 
> 	return 0;
> }
> 
> int net_udp_send(struct net_connection *con, int len)
> {
> 	if (IS_ENABLED(CONFIG_NET_PICOTCP)) {
> 		return pico_socket_sendto(con->sock, npriv->pkt,
> 				sizeof(pkt) + datalen * sizeof(uint32_t),
> 				con->ip->daddr, con->udp->uh_dport);
> 	}
> 
> 	con->udp->uh_ulen = htons(len + 8);
> 	con->udp->uh_sum = 0;
> 
> 	return net_ip_send(con, sizeof(struct udphdr) + len);
> }
> 
> The APIs between current barebox implementation and picotcp probably do
> not match exactly. Where the APIs don't match we can change the existing
> barebox API to what picotcp expects.

Yeah, picotcp uses more advanced API so we have to "pull up" existing API.

> 
> With that the remaining pieces like DHCP, netconsole and DNS would work
> without additional effort.

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-07-17  7:11 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-15 20:13 [RFC 00/12] barebox picotcp integration (2015.07.15) Antony Pavlov
2015-07-15 20:13 ` [RFC 01/12] picotcp: add barebox target support Antony Pavlov
2015-07-15 20:13 ` [RFC 02/12] picotcp: switch to Kbuild Antony Pavlov
2015-07-15 20:13 ` [RFC 03/12] net: add initial picotcp support Antony Pavlov
2015-07-15 20:13 ` [RFC 04/12] WIP: fs/nfs.c: convert to picotcp Antony Pavlov
2015-07-16 19:51   ` Sascha Hauer
2015-07-17  7:18     ` Antony Pavlov
2015-07-15 20:13 ` [RFC 05/12] WIP: fs/tftp.c: " Antony Pavlov
2015-07-15 20:13 ` [RFC 06/12] WIP: net/dns: " Antony Pavlov
2015-07-15 20:13 ` [RFC 07/12] net: picotcp: add test_picotcp command Antony Pavlov
2015-07-15 20:13 ` [RFC 08/12] net: picotcp: add ifconfig command Antony Pavlov
2015-07-15 20:13 ` [RFC 09/12] net: picotcp: add ping command Antony Pavlov
2015-07-15 20:13 ` [RFC 10/12] net: picotcp: add route command Antony Pavlov
2015-07-15 20:13 ` [RFC 11/12] sandbox_defconfig: switch to picotcp Antony Pavlov
2015-07-15 20:13 ` [RFC 12/12] WIP: sandbox_defconfig: enable network testing-related stuff Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox