barebox picotcp integration (2015.07.19)
Subsystems (3)
v2 cover barebox picotcp integration (2015.07.19)
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.
Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;
2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c404205
3. The picoping command is used insted of traditional ping command.
Antony Pavlov (16):
net_udp_bind(): use uint16_t type for source port fs/tftp.c: drop unused server_port variable fs/nfs.c: use uint16_t for port numbers fs/nfs.c: use SUNRPC_PORT remote port by default
net: change UDP handler function API
net: change net_udp_send() API
net: introduce setudppeerport()
net: import picotcp from github
picotcp: add barebox target support
picotcp: switch to Kbuild
net: add initial picotcp support
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
Makefile | 1 + arch/sandbox/configs/sandbox_defconfig | 8 +- commands/Kconfig | 4 + fs/nfs.c | 14 +- fs/tftp.c | 30 +- include/net.h | 61 +- include/pico_defines.h | 0 include/stdint.h | 1 + net/Kconfig | 16 + net/Makefile | 8 + net/dhcp.c | 12 +- net/dns.c | 9 +- net/eth.c | 71 + net/net.c | 95 +- net/netconsole.c | 7 +- net/nfs.c | 6 +- net/picotcp.c | 20 + net/picotcp/.gitignore | 25 + net/picotcp/COPYING | 8 + net/picotcp/Kconfig | 56 + net/picotcp/LICENSE | 339 ++++ net/picotcp/Makefile | 30 + net/picotcp/README.md | 33 + net/picotcp/include/arch/pico_barebox.h | 76 + net/picotcp/include/heap.h | 83 + net/picotcp/include/pico_addressing.h | 52 + net/picotcp/include/pico_config.h | 231 +++ net/picotcp/include/pico_constants.h | 54 + net/picotcp/include/pico_device.h | 54 + net/picotcp/include/pico_eth.h | 21 + net/picotcp/include/pico_frame.h | 122 ++ net/picotcp/include/pico_module_eth.h | 33 + net/picotcp/include/pico_protocol.h | 95 ++ net/picotcp/include/pico_queue.h | 166 ++ net/picotcp/include/pico_socket.h | 268 ++++ net/picotcp/include/pico_socket_multicast.h | 10 + net/picotcp/include/pico_stack.h | 87 ++ net/picotcp/include/pico_tree.h | 93 ++ net/picotcp/modules/Makefile | 8 + net/picotcp/modules/pico_aodv.h | 131 ++ net/picotcp/modules/pico_arp.c | 531 +++++++ net/picotcp/modules/pico_arp.h | 32 + net/picotcp/modules/pico_dev_loop.c | 66 + net/picotcp/modules/pico_dev_loop.h | 15 + net/picotcp/modules/pico_dev_mock.h | 47 + net/picotcp/modules/pico_dev_null.c | 60 + net/picotcp/modules/pico_dev_null.h | 15 + net/picotcp/modules/pico_dhcp_client.c | 960 ++++++++++++ net/picotcp/modules/pico_dhcp_client.h | 30 + net/picotcp/modules/pico_dhcp_common.c | 189 +++ net/picotcp/modules/pico_dhcp_common.h | 186 +++ net/picotcp/modules/pico_dns_client.h | 46 + net/picotcp/modules/pico_dns_common.h | 521 +++++++ net/picotcp/modules/pico_dns_sd.h | 90 ++ net/picotcp/modules/pico_fragments.c | 345 +++++ net/picotcp/modules/pico_fragments.h | 11 + net/picotcp/modules/pico_icmp4.c | 395 +++++ net/picotcp/modules/pico_icmp4.h | 162 ++ net/picotcp/modules/pico_icmp6.h | 259 ++++ net/picotcp/modules/pico_igmp.h | 26 + net/picotcp/modules/pico_ipfilter.h | 29 + net/picotcp/modules/pico_ipv4.c | 1574 +++++++++++++++++++ net/picotcp/modules/pico_ipv4.h | 124 ++ net/picotcp/modules/pico_ipv6.h | 153 ++ net/picotcp/modules/pico_ipv6_nd.h | 26 + net/picotcp/modules/pico_mm.h | 98 ++ net/picotcp/modules/pico_nat.h | 90 ++ net/picotcp/modules/pico_olsr.h | 32 + net/picotcp/modules/pico_socket_tcp.h | 33 + net/picotcp/modules/pico_socket_udp.c | 250 +++ net/picotcp/modules/pico_socket_udp.h | 19 + net/picotcp/modules/pico_tcp.h | 102 ++ net/picotcp/modules/pico_udp.c | 216 +++ net/picotcp/modules/pico_udp.h | 45 + net/picotcp/stack/Makefile | 7 + net/picotcp/stack/pico_device.c | 408 +++++ net/picotcp/stack/pico_frame.c | 286 ++++ net/picotcp/stack/pico_protocol.c | 214 +++ net/picotcp/stack/pico_socket.c | 2213 +++++++++++++++++++++++++++ net/picotcp/stack/pico_socket_multicast.c | 956 ++++++++++++ net/picotcp/stack/pico_stack.c | 1157 ++++++++++++++ net/picotcp/stack/pico_tree.c | 575 +++++++ net/picotcp_ifconfig.c | 116 ++ net/picotcp_ping.c | 85 + net/picotcp_route.c | 36 + net/picotcp_test_ipv4.c | 96 ++ 86 files changed, 15306 insertions(+), 58 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/.gitignore create mode 100644 net/picotcp/COPYING create mode 100644 net/picotcp/Kconfig create mode 100644 net/picotcp/LICENSE create mode 100644 net/picotcp/Makefile create mode 100644 net/picotcp/README.md create mode 100644 net/picotcp/include/arch/pico_barebox.h create mode 100644 net/picotcp/include/heap.h create mode 100644 net/picotcp/include/pico_addressing.h create mode 100644 net/picotcp/include/pico_config.h create mode 100644 net/picotcp/include/pico_constants.h create mode 100644 net/picotcp/include/pico_device.h create mode 100644 net/picotcp/include/pico_eth.h create mode 100644 net/picotcp/include/pico_frame.h create mode 100644 net/picotcp/include/pico_module_eth.h create mode 100644 net/picotcp/include/pico_protocol.h create mode 100644 net/picotcp/include/pico_queue.h create mode 100644 net/picotcp/include/pico_socket.h create mode 100644 net/picotcp/include/pico_socket_multicast.h create mode 100644 net/picotcp/include/pico_stack.h create mode 100644 net/picotcp/include/pico_tree.h create mode 100644 net/picotcp/modules/Makefile create mode 100644 net/picotcp/modules/pico_aodv.h create mode 100644 net/picotcp/modules/pico_arp.c create mode 100644 net/picotcp/modules/pico_arp.h create mode 100644 net/picotcp/modules/pico_dev_loop.c create mode 100644 net/picotcp/modules/pico_dev_loop.h create mode 100644 net/picotcp/modules/pico_dev_mock.h create mode 100644 net/picotcp/modules/pico_dev_null.c create mode 100644 net/picotcp/modules/pico_dev_null.h create mode 100644 net/picotcp/modules/pico_dhcp_client.c create mode 100644 net/picotcp/modules/pico_dhcp_client.h create mode 100644 net/picotcp/modules/pico_dhcp_common.c create mode 100644 net/picotcp/modules/pico_dhcp_common.h create mode 100644 net/picotcp/modules/pico_dns_client.h create mode 100644 net/picotcp/modules/pico_dns_common.h create mode 100644 net/picotcp/modules/pico_dns_sd.h create mode 100644 net/picotcp/modules/pico_fragments.c create mode 100644 net/picotcp/modules/pico_fragments.h create mode 100644 net/picotcp/modules/pico_icmp4.c create mode 100644 net/picotcp/modules/pico_icmp4.h create mode 100644 net/picotcp/modules/pico_icmp6.h create mode 100644 net/picotcp/modules/pico_igmp.h create mode 100644 net/picotcp/modules/pico_ipfilter.h create mode 100644 net/picotcp/modules/pico_ipv4.c create mode 100644 net/picotcp/modules/pico_ipv4.h create mode 100644 net/picotcp/modules/pico_ipv6.h create mode 100644 net/picotcp/modules/pico_ipv6_nd.h create mode 100644 net/picotcp/modules/pico_mm.h create mode 100644 net/picotcp/modules/pico_nat.h create mode 100644 net/picotcp/modules/pico_olsr.h create mode 100644 net/picotcp/modules/pico_socket_tcp.h create mode 100644 net/picotcp/modules/pico_socket_udp.c create mode 100644 net/picotcp/modules/pico_socket_udp.h create mode 100644 net/picotcp/modules/pico_tcp.h create mode 100644 net/picotcp/modules/pico_udp.c create mode 100644 net/picotcp/modules/pico_udp.h create mode 100644 net/picotcp/stack/Makefile create mode 100644 net/picotcp/stack/pico_device.c create mode 100644 net/picotcp/stack/pico_frame.c create mode 100644 net/picotcp/stack/pico_protocol.c create mode 100644 net/picotcp/stack/pico_socket.c create mode 100644 net/picotcp/stack/pico_socket_multicast.c create mode 100644 net/picotcp/stack/pico_stack.c create mode 100644 net/picotcp/stack/pico_tree.c 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
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 1/16 net_udp_bind(): use uint16_t type for source port
--- include/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net.h +1 -1
@@ -445,7 +445,7 @@ struct net_connection *net_icmp_new(IPaddr_t dest, rx_handler_f *handler,void net_unregister (struct net_connection *con); -static inline int net_udp_bind (struct net_connection *con,int sport) +static inline int net_udp_bind (struct net_connection *con,uint16_t sport) { con->udp->uh_sport =ntohs (sport);return 0 ;
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 2/16 fs/tftp.c: drop unused server_port variable
In reply to Antony Pavlov--- fs/tftp.c | 3 --- 1 file changed, 3 deletions(-)
fs/tftp.c +0 -3
@@ -75,7 +75,6 @@ struct file_priv {uint16_t last_block;int state;int err; -int server_port;const char *filename;int filesize;uint64_t resend_timeout;
@@ -299,7 +298,6 @@ static void tftp_recv(struct file_priv *priv,case TFTP_OACK :tftp_parse_oack (priv, pkt, len); - priv->server_port =ntohs (uh_sport); priv->tftp_con->udp->uh_dport = uh_sport;if (priv->push) {
@@ -322,7 +320,6 @@ static void tftp_recv(struct file_priv *priv,/* first block received */ priv->state =STATE_RDATA ; priv->tftp_con->udp->uh_dport = uh_sport; - priv->server_port =ntohs (uh_sport); priv->last_block =0 ;if (priv->block !=1 ) {/* Assertion */
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 3/16 fs/nfs.c: use uint16_t for port numbers
In reply to Antony Pavlov--- fs/nfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs.c +2 -2
@@ -132,8 +132,8 @@ struct nfs_priv {struct net_connection *con;IPaddr_t server;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 ];
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 4/16 fs/nfs.c: use SUNRPC_PORT remote port by default
In reply to Antony Pavlovpico_socket_connect() needs remote_port != 0.
--- fs/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs.c +1 -1
@@ -1350,7 +1350,7 @@ static int nfs_probe(struct device_d *dev)debug ("nfs: server: %s path: %s\n" , tmp, npriv->path); - npriv->con =net_udp_new (npriv->server,0 , nfs_handler, npriv); + npriv->con =net_udp_new (npriv->server,SUNRPC_PORT , nfs_handler, npriv);if (IS_ERR (npriv->con)) { ret =PTR_ERR (npriv->con); goto err1;
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 5/16 net: change UDP handler function API
In reply to Antony Pavlov--- fs/nfs.c | 4 +--- fs/tftp.c | 9 +++------ include/net.h | 15 +++++++++++++-- net/dhcp.c | 8 ++------ net/dns.c | 7 +++---- net/net.c | 12 ++++++++---- net/netconsole.c | 5 ++--- net/nfs.c | 3 +-- 8 files changed, 33 insertions(+), 30 deletions(-)
fs/nfs.c +1 -3
@@ -943,10 +943,8 @@ static int nfs_read_req(struct file_priv *priv, uint64_t offset,return 0 ; } -static void nfs_handler (void *ctx,char *packet,unsigned len) +static void nfs_handler (struct net_connection *con,char *pkt,unsigned len) { -char *pkt =net_eth_to_udp_payload (packet); - nfs_state =STATE_DONE ; nfs_packet = pkt; nfs_len = len;
fs/tftp.c +3 -6
@@ -368,14 +368,11 @@ static void tftp_recv(struct file_priv *priv, } } -static void tftp_handler (void *ctx,char *packet,unsigned len) +static void tftp_handler (struct net_connection *con,char *packet,unsigned len) { -struct file_priv *priv = ctx; -char *pkt =net_eth_to_udp_payload (packet); -struct udphdr *udp =net_eth_to_udphdr (packet); +struct file_priv *priv = con->priv; - (void )len; -tftp_recv (priv, pkt,net_eth_to_udplen (packet), udp->uh_sport); +tftp_recv (priv, packet, len,getudppeerport (con)); } static struct file_priv *tftp_do_open(struct device_d *dev,
include/net.h +13 -2
@@ -405,6 +405,8 @@ static inline int is_valid_ether_addr(const u8 *addr) }typedef void rx_handler_f (void *ctx,char *packet,unsigned int len); +struct net_connection ; +typedef void udp_rx_handler_f (struct net_connection *con,char *packet,unsigned int len);void eth_set_current (struct eth_device *eth);struct eth_device *eth_get_current (void );
@@ -426,8 +428,9 @@ struct net_connection {struct eth_device *edev;struct icmphdr *icmp;unsigned char *packet; +unsigned char *rpacket;struct list_head list; -rx_handler_f *handler; +void *handler;int proto;void *priv; };
@@ -438,7 +441,7 @@ static inline char *net_alloc_packet(void) }struct net_connection *net_udp_new (IPaddr_t dest,uint16_t dport, -rx_handler_f *handler,void *ctx); +udp_rx_handler_f *handler,void *ctx);struct net_connection *net_icmp_new (IPaddr_t dest,rx_handler_f *handler,void *ctx);
@@ -467,4 +470,12 @@ void led_trigger_network(enum led_trigger trigger);int ifup (const char *name,unsigned flags);int ifup_all (unsigned flags); +/* NB! return port in network byte order */ +static inline uint16_t getudppeerport (struct net_connection *con) +{ +struct udphdr *udp =net_eth_to_udphdr (con->rpacket); + +return udp->uh_sport; +} +#endif /* __NET_H__ */
net/dhcp.c +2 -6
@@ -588,18 +588,14 @@ static void dhcp_send_request_packet(struct bootp *bp_offer)/* * Handle DHCP received packets. */ -static void dhcp_handler (void *ctx,char *packet,unsigned int len) +static void dhcp_handler (struct net_connection *con,char *pkt,unsigned int len) { -char *pkt =net_eth_to_udp_payload (packet); -struct udphdr *udp =net_eth_to_udphdr (packet);struct bootp *bp = (struct bootp *)pkt; - len =net_eth_to_udplen (packet); -debug ("DHCPHandler: got packet: (len=%d) state: %d\n" , len, dhcp_state); -if (bootp_check_packet (pkt,ntohs (udp->uh_sport), len))/* Filter out pkts we don't want */ +if (bootp_check_packet (pkt,ntohs (getudppeerport (con)), len))/* Filter out pkts we don't want */ return ;switch (dhcp_state) {
net/dns.c +3 -4
@@ -192,11 +192,10 @@ static void dns_recv(struct header *header, unsigned len) } } -static void dns_handler (void *ctx,char *packet,unsigned len) +static void dns_handler (struct net_connection *con,char *packet,unsigned len) { - (void )ctx; -dns_recv ((struct header *)net_eth_to_udp_payload (packet), -net_eth_to_udplen (packet)); + (void )con; +dns_recv ((struct header *)packet, len); }IPaddr_t resolv (char *host)
net/net.c +8 -4
@@ -255,7 +255,7 @@ void net_set_gateway(IPaddr_t gw)static LIST_HEAD (connection_list); -static struct net_connection *net_new (IPaddr_t dest,rx_handler_f *handler, +static struct net_connection *net_new (IPaddr_t dest,void *handler,void *ctx) {struct eth_device *edev =eth_get_current ();
@@ -317,7 +317,7 @@ out: }struct net_connection *net_udp_new (IPaddr_t dest,uint16_t dport, -rx_handler_f *handler,void *ctx) +udp_rx_handler_f *handler,void *ctx) {struct net_connection *con =net_new (dest, handler, ctx);
@@ -480,7 +480,10 @@ static int net_handle_udp(unsigned char *pkt, int len) port =ntohs (udp->uh_dport);list_for_each_entry (con, &connection_list, list) {if (con->proto ==IPPROTO_UDP && port ==ntohs (con->udp->uh_sport)) { - con->handler (con->priv, pkt, len); +udp_rx_handler_f *handler = con->handler; + con->rpacket = pkt; +handler (con,net_eth_to_udp_payload (pkt), +net_eth_to_udplen (pkt));return 0 ; } }
@@ -495,7 +498,8 @@ static int net_handle_icmp(unsigned char *pkt, int len)list_for_each_entry (con, &connection_list, list) {if (con->proto ==IPPROTO_ICMP ) { - con->handler (con->priv, pkt, len); +rx_handler_f *handler = con->handler; +handler (con->priv, pkt, len);return 0 ; } }
net/netconsole.c +2 -3
@@ -44,12 +44,11 @@ struct nc_priv {static struct nc_priv *g_priv; -static void nc_handler (void *ctx,char *pkt,unsigned len) +static void nc_handler (struct net_connection *con,char *pkt,unsigned len) {struct nc_priv *priv = g_priv; -unsigned char *packet =net_eth_to_udp_payload (pkt); -kfifo_put (priv->fifo, packet,net_eth_to_udplen (pkt)); +kfifo_put (priv->fifo, pkt, len); }static int nc_getc (struct console_device *cdev)
net/nfs.c +1 -2
@@ -562,9 +562,8 @@ static int nfs_read_reply(unsigned char *pkt, unsigned len)Interfaces of barebox **************************************************************************/ -static void nfs_handler (void *ctx,char *packet,unsigned len) +static void nfs_handler (struct net_connection *con,char *pkt,unsigned len) { -char *pkt =net_eth_to_udp_payload (packet);int ret;debug ("%s\n" , __func__);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 6/16 net: change net_udp_send() API
In reply to Antony Pavlov--- fs/nfs.c | 2 +- fs/tftp.c | 9 +++++---- include/net.h | 2 +- net/dhcp.c | 4 ++-- net/dns.c | 2 +- net/net.c | 2 +- net/netconsole.c | 2 +- net/nfs.c | 3 ++- 8 files changed, 14 insertions(+), 12 deletions(-)
fs/nfs.c +1 -1
@@ -414,7 +414,7 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc, npriv->con->udp->uh_dport =hton16 (dport); again: - ret =net_udp_send (npriv->con, + ret =net_udp_send (npriv->con, payload,sizeof (pkt) + datalen *sizeof (uint32_t )); nfs_timer_start =get_time_ns ();
fs/tftp.c +5 -4
@@ -119,7 +119,8 @@ 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 *payload =net_udp_get_payload (priv->tftp_con); +uint8_t *pkt = payload;int ret;debug ("%s: state %d\n" , __func__, priv->state);
@@ -168,7 +169,7 @@ static int tftp_send(struct file_priv *priv)break ; } - ret =net_udp_send (priv->tftp_con, len); + ret =net_udp_send (priv->tftp_con, payload, len);return ret; }
@@ -187,7 +188,7 @@ 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); + ret =net_udp_send (priv->tftp_con, pkt, len); priv->last_block = priv->block; priv->state =STATE_WAITACK ;
@@ -501,7 +502,7 @@ static int tftp_do_close(struct file_priv *priv) *pkt++ =htons (TFTP_ERROR ); *pkt++ =0 ; *pkt++ =0 ; -net_udp_send (priv->tftp_con,6 ); +net_udp_send (priv->tftp_con, (char *)pkt,6 ); }net_unregister (priv->tftp_con);
include/net.h +1 -1
@@ -460,7 +460,7 @@ static inline void *net_udp_get_payload(struct net_connection *con)sizeof (struct udphdr ); } -int net_udp_send (struct net_connection *con,int len); +int net_udp_send (struct net_connection *con,char *payload,int len);int net_icmp_send (struct net_connection *con,int len);void led_trigger_network (enum led_trigger trigger);
net/dhcp.c +2 -2
@@ -487,7 +487,7 @@ static int bootp_request(void) dhcp_state =SELECTING ; - ret =net_udp_send (dhcp_con,sizeof (*bp) + ext_len); + ret =net_udp_send (dhcp_con, payload,sizeof (*bp) + ext_len);return ret; }
@@ -582,7 +582,7 @@ static void dhcp_send_request_packet(struct bootp *bp_offer) OfferedIP);debug ("Transmitting DHCPREQUEST packet\n" ); -net_udp_send (dhcp_con,sizeof (*bp) + extlen); +net_udp_send (dhcp_con, payload,sizeof (*bp) + extlen); }/*
net/dns.c +1 -1
@@ -109,7 +109,7 @@ static int dns_send(char *name) *p++ =0 ; *p++ =1 ;/* Class: inet, 0x0001 */ - ret =net_udp_send (dns_con, p - packet); + ret =net_udp_send (dns_con, packet, p - packet);free (fullname);
net/net.c +1 -1
@@ -363,7 +363,7 @@ static int net_ip_send(struct net_connection *con, int len)return eth_send (con->edev, con->packet,ETHER_HDR_SIZE +sizeof (struct iphdr ) + len); } -int net_udp_send (struct net_connection *con,int len) +int net_udp_send (struct net_connection *con,char *payload,int len) { con->udp->uh_ulen =htons (len +8 ); con->udp->uh_sum =0 ;
net/netconsole.c +1 -1
@@ -100,7 +100,7 @@ static void nc_putc(struct console_device *cdev, char c) *packet = c; priv->busy =1 ; -net_udp_send (priv->con,1 ); +net_udp_send (priv->con, packet,1 ); priv->busy =0 ; }
net/nfs.c +2 -1
@@ -225,7 +225,8 @@ static int rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) sport = nfs_server_nfs_port; nfs_con->udp->uh_dport =htons (sport); - ret =net_udp_send (nfs_con,sizeof (pkt) + datalen *sizeof (uint32_t )); + ret =net_udp_send (nfs_con, payload, +sizeof (pkt) + datalen *sizeof (uint32_t ));return ret; }
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 7/16 net: introduce setudppeerport()
In reply to Antony Pavlov--- fs/nfs.c | 2 +- fs/tftp.c | 9 +++++---- include/net.h | 7 +++++++ 3 files changed, 13 insertions(+), 5 deletions(-)
fs/nfs.c +1 -1
@@ -411,7 +411,7 @@ static int rpc_req(struct nfs_priv *npriv, int rpc_prog, int rpc_proc,memcpy (payload, &pkt,sizeof (pkt));memcpy (payload +sizeof (pkt), data, datalen *sizeof (uint32_t )); - npriv->con->udp->uh_dport =hton16 (dport); +setudppeerport (npriv->con,htons (dport)); again: ret = net_udp_send(npriv->con, payload,
fs/tftp.c +5 -4
@@ -177,7 +177,7 @@ 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 =net_udp_get_payload (priv->tftp_con);int ret; s = (uint16_t *)pkt;
@@ -293,13 +293,14 @@ static void tftp_recv(struct file_priv *priv, priv->state =STATE_DONE ;break ; } - priv->tftp_con->udp->uh_dport = uh_sport; +setudppeerport (priv->tftp_con, uh_sport); + priv->state =STATE_WDATA ;break ;case TFTP_OACK :tftp_parse_oack (priv, pkt, len); - priv->tftp_con->udp->uh_dport = uh_sport; +setudppeerport (priv->tftp_con, uh_sport);if (priv->push) {/* send first block */
@@ -320,7 +321,7 @@ 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; +setudppeerport (priv->tftp_con, uh_sport); priv->last_block =0 ;if (priv->block !=1 ) {/* Assertion */
include/net.h +7 -0
@@ -478,4 +478,11 @@ static inline uint16_t getudppeerport(struct net_connection *con) return udp->uh_sport; } +#include <byteorder.h> + +static inline void setudppeerport (struct net_connection *con,uint16_t dport) +{ + con->udp->uh_dport = dport; +} +#endif /* __NET_H__ */
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 8/16 net: import picotcp from github
In reply to Antony PavlovOriginal repo: https://github.com/tass-belgium/picotcp
The last original repo commit is v1.5.0
commit f6d139147d86d74f9a53ba3c02b2a5b276858d95
Author: laurens <[email protected]>
Date: Thu Jun 25 12:54:38 2015 +0100
Remove old check from fragments module
from development branch
Import mini-howto:
$ cd barebox.git
$ rm -rf net/picotcp
$ git clone --branch ${branch_name} ${PICOTCP_REPO} net/picotcp
$ rm -rf net/picotcp/*
$ ( cd net/picotcp; git checkout .gitignore COPYING LICENSE README.md )
$ ( cd net/picotcp; mkdir include modules stack )
$ ( cd net/picotcp/include; git checkout heap.h pico_addressing.h pico_config.h pico_constants.h pico_device.h pico_eth.h pico_frame.h pico_module_eth.h pico_protocol.h pico_queue.h pico_socket.h pico_socket_multicast.h pico_stack.h pico_tree.h )
$ ( cd net/picotcp/modules; git checkout pico_aodv.h pico_arp.c pico_arp.h pico_dev_loop.c pico_dev_loop.h pico_dev_mock.h pico_dev_null.c pico_dev_null.h pico_dhcp_client.c pico_dhcp_client.h pico_dhcp_common.c pico_dhcp_common.h pico_dns_client.h pico_dns_common.h pico_dns_sd.h pico_fragments.c pico_fragments.h pico_icmp4.c pico_icmp4.h pico_icmp6.h pico_igmp.h pico_ipfilter.h pico_ipv4.c pico_ipv4.h pico_ipv6.h pico_ipv6_nd.h pico_mm.h pico_nat.h pico_olsr.h pico_socket_tcp.h pico_socket_udp.c pico_socket_udp.h pico_tcp.h pico_udp.c pico_udp.h )
$ ( cd net/picotcp/stack; git checkout pico_device.c pico_frame.c pico_protocol.c pico_socket.c pico_socket_multicast.c pico_stack.c pico_tree.c )
$ rm -rf net/picotcp/.git
$ git add net/picotcp/
$ git commit -s--- net/picotcp/.gitignore | 24 + net/picotcp/COPYING | 8 + net/picotcp/LICENSE | 339 ++++ net/picotcp/README.md | 33 + net/picotcp/include/heap.h | 83 + net/picotcp/include/pico_addressing.h | 52 + net/picotcp/include/pico_config.h | 229 +++ net/picotcp/include/pico_constants.h | 54 + net/picotcp/include/pico_device.h | 54 + net/picotcp/include/pico_eth.h | 21 + net/picotcp/include/pico_frame.h | 122 ++ net/picotcp/include/pico_module_eth.h | 33 + net/picotcp/include/pico_protocol.h | 95 ++ net/picotcp/include/pico_queue.h | 166 ++ net/picotcp/include/pico_socket.h | 268 ++++ net/picotcp/include/pico_socket_multicast.h | 10 + net/picotcp/include/pico_stack.h | 87 ++ net/picotcp/include/pico_tree.h | 93 ++ net/picotcp/modules/pico_aodv.h | 131 ++ net/picotcp/modules/pico_arp.c | 531 +++++++ net/picotcp/modules/pico_arp.h | 32 + net/picotcp/modules/pico_dev_loop.c | 66 + net/picotcp/modules/pico_dev_loop.h | 15 + net/picotcp/modules/pico_dev_mock.h | 47 + net/picotcp/modules/pico_dev_null.c | 60 + net/picotcp/modules/pico_dev_null.h | 15 + net/picotcp/modules/pico_dhcp_client.c | 960 ++++++++++++ net/picotcp/modules/pico_dhcp_client.h | 30 + net/picotcp/modules/pico_dhcp_common.c | 189 +++ net/picotcp/modules/pico_dhcp_common.h | 186 +++ net/picotcp/modules/pico_dns_client.h | 46 + net/picotcp/modules/pico_dns_common.h | 521 +++++++ net/picotcp/modules/pico_dns_sd.h | 90 ++ net/picotcp/modules/pico_fragments.c | 345 +++++ net/picotcp/modules/pico_fragments.h | 11 + net/picotcp/modules/pico_icmp4.c | 395 +++++ net/picotcp/modules/pico_icmp4.h | 162 ++ net/picotcp/modules/pico_icmp6.h | 259 ++++ net/picotcp/modules/pico_igmp.h | 26 + net/picotcp/modules/pico_ipfilter.h | 29 + net/picotcp/modules/pico_ipv4.c | 1574 +++++++++++++++++++ net/picotcp/modules/pico_ipv4.h | 124 ++ net/picotcp/modules/pico_ipv6.h | 153 ++ net/picotcp/modules/pico_ipv6_nd.h | 26 + net/picotcp/modules/pico_mm.h | 98 ++ net/picotcp/modules/pico_nat.h | 90 ++ net/picotcp/modules/pico_olsr.h | 32 + net/picotcp/modules/pico_socket_tcp.h | 33 + net/picotcp/modules/pico_socket_udp.c | 250 +++ net/picotcp/modules/pico_socket_udp.h | 19 + net/picotcp/modules/pico_tcp.h | 102 ++ net/picotcp/modules/pico_udp.c | 216 +++ net/picotcp/modules/pico_udp.h | 45 + net/picotcp/stack/pico_device.c | 408 +++++ net/picotcp/stack/pico_frame.c | 286 ++++ net/picotcp/stack/pico_protocol.c | 214 +++ net/picotcp/stack/pico_socket.c | 2213 +++++++++++++++++++++++++++ net/picotcp/stack/pico_socket_multicast.c | 956 ++++++++++++ net/picotcp/stack/pico_stack.c | 1157 ++++++++++++++ net/picotcp/stack/pico_tree.c | 575 +++++++ 60 files changed, 14488 insertions(+)
net/picotcp/.gitignore new file +24 -0
@@ -0,0 +1,24 @@ +*.d +*.o +*.a +*.out +*.swp +tags +build +UNIT_* +core +core.* +.DS_Store +cscope.files +cscope.out +*.so +*.aux +*.pdf +*.toc +*.gz +*.log +*.pyc +*.elf +*.gcov +*.gcda +*.gcno
net/picotcp/COPYING new file +8 -0
@@ -0,0 +1,8 @@ +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. + +Released under the GNU General Public License, version 2. +See LICENSE for details. + +Different licensing models may exist, at the sole discretion of +the Copyright holders. +
net/picotcp/LICENSE new file +339 -0
339 lines not on this page · raw message
net/picotcp/README.md new file +33 -0
@@ -0,0 +1,33 @@ +picoTCP + +--------------- + +Welcome to the one and only <font color=ff00f0>picoTCP repository</font>. + +picoTCP is a small-footprint, modular TCP/IP stack designed for embedded systems and the Internet of Things. It's actively being developed by *[Altran Intelligent Systems](http://intelligent-systems.altran.com/)*. + +This code is released under the terms of GNU GPL v2 only. Some rights reserved. +Other licenses may apply at the sole discretion of the copyright holders. + +Learn how to use picoTCP in your project by going through the Getting Started guide on our [GitHub wiki](https://github.com/tass-belgium/picotcp/wiki). + +For more information visit the [picoTCP website](http://www.picotcp.com), send us an email or contact us on [Twitter](https://twitter.com/picotcp), [Facebook](https://www.facebook.com/picoTCP) or [Reddit](http://www.reddit.com/r/picotcp/). + +Wondering about picoTCP's code quality? Check [our TiCS score](http://tics.picotcp.com:42506/TIOBEPortal/TICS/treeviewer?) + + +--------------- + +Continuous integration + +Jenkins Functional tests: +[](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_autotest) + +Jenkins Unit tests : +[](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_unit_tests) + +Jenkins RFC compliance : +[](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_RF_mbed) + +Jenkins TICS quality : +[](http://jenkins.picotcp.com:8080/job/PicoTCP_rel_TICS/)
net/picotcp/include/heap.h new file +83 -0
83 lines not on this page · raw message
net/picotcp/include/pico_addressing.h new file +52 -0
52 lines not on this page · raw message
net/picotcp/include/pico_config.h new file +229 -0
229 lines not on this page · raw message
net/picotcp/include/pico_constants.h new file +54 -0
54 lines not on this page · raw message
net/picotcp/include/pico_device.h new file +54 -0
54 lines not on this page · raw message
net/picotcp/include/pico_eth.h new file +21 -0
@@ -0,0 +1,21 @@ +/********************************************************************* +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. +See LICENSE and COPYING for usage. + +*********************************************************************/ +#ifndef INCLUDE_PICO_ETH +#define INCLUDE_PICO_ETH +#include "pico_addressing.h" +#include "pico_ipv4.h" +#include "pico_ipv6.h" + + +PACKED_STRUCT_DEF pico_eth_hdr { +uint8_t daddr[6 ]; +uint8_t saddr[6 ]; +uint16_t proto; +}; + +#define PICO_SIZE_ETHHDR 14 + +#endif
net/picotcp/include/pico_frame.h new file +122 -0
122 lines not on this page · raw message
net/picotcp/include/pico_module_eth.h new file +33 -0
@@ -0,0 +1,33 @@ +/********************************************************************* +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. +See LICENSE and COPYING for usage. + +*********************************************************************/ +#ifndef PICO_MODULE_IPV4_H +#define PICO_MODULE_IPV4_H + +struct pico_arp_entry { +struct eth dest; +#ifdef PICO_CONFIG_IPV4 +struct ipv4 addr_ipv4; +#endif +RB_ENTRY (pico_arp_entry) node; +}; + +/* Configured device */ +struct pico_eth_link { +struct pico_device *dev; +struct eth address; +struct eth netmask; +RB_ENTRY (pico_eth_link) node; +}; + +#ifndef IS_MODULE_ETH +# define _mod extern +#else +# define _mod +#endif +_mod struct pico_module pico_module_eth; +#undef _mod + +#endif
net/picotcp/include/pico_protocol.h new file +95 -0
95 lines not on this page · raw message
net/picotcp/include/pico_queue.h new file +166 -0
166 lines not on this page · raw message
net/picotcp/include/pico_socket.h new file +268 -0
268 lines not on this page · raw message
net/picotcp/include/pico_socket_multicast.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef PICO_SOCKET_MULTICAST_H +#define PICO_SOCKET_MULTICAST_H +int pico_socket_mcast_filter (struct pico_socket *s,union pico_address *mcast_group,union pico_address *src); +void pico_multicast_delete (struct pico_socket *s); +int pico_setsockopt_mcast (struct pico_socket *s,int option,void *value); +int pico_getsockopt_mcast (struct pico_socket *s,int option,void *value); +int pico_udp_get_mc_ttl (struct pico_socket *s,uint8_t *ttl); +int pico_udp_set_mc_ttl (struct pico_socket *s,void *_ttl); + +#endif
net/picotcp/include/pico_stack.h new file +87 -0
87 lines not on this page · raw message
net/picotcp/include/pico_tree.h new file +93 -0
93 lines not on this page · raw message
net/picotcp/modules/pico_aodv.h new file +131 -0
131 lines not on this page · raw message
net/picotcp/modules/pico_arp.c new file +531 -0
531 lines not on this page · raw message
net/picotcp/modules/pico_arp.h new file +32 -0
@@ -0,0 +1,32 @@ +/********************************************************************* +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. +See LICENSE and COPYING for usage. + +*********************************************************************/ +#ifndef INCLUDE_PICO_ARP +#define INCLUDE_PICO_ARP +#include "pico_eth.h" +#include "pico_device.h" + +int pico_arp_receive (struct pico_frame *); + + +struct pico_eth *pico_arp_get (struct pico_frame *f); +int32_t pico_arp_request (struct pico_device *dev,struct pico_ip4 *dst,uint8_t type); + +#define PICO_ARP_STATUS_REACHABLE 0x00 +#define PICO_ARP_STATUS_PERMANENT 0x01 +#define PICO_ARP_STATUS_STALE 0x02 + +#define PICO_ARP_QUERY 0x00 +#define PICO_ARP_PROBE 0x01 +#define PICO_ARP_ANNOUNCE 0x02 + +struct pico_eth *pico_arp_lookup (struct pico_ip4 *dst); +struct pico_ip4 *pico_arp_reverse_lookup (struct pico_eth *dst); +int pico_arp_create_entry (uint8_t *hwaddr,struct pico_ip4 ipv4,struct pico_device *dev); +int pico_arp_get_neighbors (struct pico_device *dev,struct pico_ip4 *neighbors,int maxlen); +void pico_arp_register_ipconflict (struct pico_ip4 *ip,struct pico_eth *mac,void (*cb)(void )); +void pico_arp_postpone (struct pico_frame *f); +void pico_arp_init (void ); +#endif
net/picotcp/modules/pico_dev_loop.c new file +66 -0
66 lines not on this page · raw message
net/picotcp/modules/pico_dev_loop.h new file +15 -0
@@ -0,0 +1,15 @@ +/********************************************************************* +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. +See LICENSE and COPYING for usage. + +*********************************************************************/ +#ifndef INCLUDE_PICO_LOOP +#define INCLUDE_PICO_LOOP +#include "pico_config.h" +#include "pico_device.h" + +void pico_loop_destroy (struct pico_device *loop); +struct pico_device *pico_loop_create (void ); + +#endif +
net/picotcp/modules/pico_dev_mock.h new file +47 -0
47 lines not on this page · raw message
net/picotcp/modules/pico_dev_null.c new file +60 -0
60 lines not on this page · raw message
net/picotcp/modules/pico_dev_null.h new file +15 -0
@@ -0,0 +1,15 @@ +/********************************************************************* +PicoTCP. Copyright (c) 2012-2015 Altran Intelligent Systems. Some rights reserved. +See LICENSE and COPYING for usage. + +*********************************************************************/ +#ifndef INCLUDE_PICO_NULL +#define INCLUDE_PICO_NULL +#include "pico_config.h" +#include "pico_device.h" + +void pico_null_destroy (struct pico_device *null); +struct pico_device *pico_null_create (char *name); + +#endif +
net/picotcp/modules/pico_dhcp_client.c new file +960 -0
332 lines not on this page · raw message
net/picotcp/modules/pico_dhcp_client.h new file +30 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_dhcp_common.c new file +189 -0
189 lines not on this page · raw message
net/picotcp/modules/pico_dhcp_common.h new file +186 -0
186 lines not on this page · raw message
net/picotcp/modules/pico_dns_client.h new file +46 -0
46 lines not on this page · raw message
net/picotcp/modules/pico_dns_common.h new file +521 -0
521 lines not on this page · raw message
net/picotcp/modules/pico_dns_sd.h new file +90 -0
90 lines not on this page · raw message
net/picotcp/modules/pico_fragments.c new file +345 -0
345 lines not on this page · raw message
net/picotcp/modules/pico_fragments.h new file +11 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_icmp4.c new file +395 -0
395 lines not on this page · raw message
net/picotcp/modules/pico_icmp4.h new file +162 -0
162 lines not on this page · raw message
net/picotcp/modules/pico_icmp6.h new file +259 -0
259 lines not on this page · raw message
net/picotcp/modules/pico_igmp.h new file +26 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_ipfilter.h new file +29 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_ipv4.c new file +1574 -0
1,574 lines not on this page · raw message
net/picotcp/modules/pico_ipv4.h new file +124 -0
124 lines not on this page · raw message
net/picotcp/modules/pico_ipv6.h new file +153 -0
153 lines not on this page · raw message
net/picotcp/modules/pico_ipv6_nd.h new file +26 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_mm.h new file +98 -0
98 lines not on this page · raw message
net/picotcp/modules/pico_nat.h new file +90 -0
90 lines not on this page · raw message
net/picotcp/modules/pico_olsr.h new file +32 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_socket_tcp.h new file +33 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_socket_udp.c new file +250 -0
250 lines not on this page · raw message
net/picotcp/modules/pico_socket_udp.h new file +19 -0
Lines of this file are not shown. View the raw message.
net/picotcp/modules/pico_tcp.h new file +102 -0
102 lines not on this page · raw message
net/picotcp/modules/pico_udp.c new file +216 -0
216 lines not on this page · raw message
net/picotcp/modules/pico_udp.h new file +45 -0
45 lines not on this page · raw message
net/picotcp/stack/pico_device.c new file +408 -0
408 lines not on this page · raw message
net/picotcp/stack/pico_frame.c new file +286 -0
286 lines not on this page · raw message
net/picotcp/stack/pico_protocol.c new file +214 -0
214 lines not on this page · raw message
net/picotcp/stack/pico_socket.c new file +2213 -0
2,213 lines not on this page · raw message
net/picotcp/stack/pico_socket_multicast.c new file +956 -0
956 lines not on this page · raw message
net/picotcp/stack/pico_stack.c new file +1157 -0
1,157 lines not on this page · raw message
net/picotcp/stack/pico_tree.c new file +575 -0
575 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Part of the diff is not shown here. View the raw message.
RFC v2 9/16 picotcp: add barebox target support
In reply to Antony Pavlov--- net/picotcp/include/arch/pico_barebox.h | 76 +++++++++++++++++++++++++++++++++ net/picotcp/include/pico_config.h | 2 + 2 files changed, 78 insertions(+)
net/picotcp/include/arch/pico_barebox.h new file +76 -0
@@ -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 */
net/picotcp/include/pico_config.h +2 -0
@@ -211,6 +211,8 @@ static inline uint64_t long_long_be(uint64_t le)# include "arch/pico_none.h" #elif definedGENERIC # include "arch/pico_generic_gcc.h" +#elif defined __BAREBOX__ +# include "arch/pico_barebox.h" #elif defined __KERNEL__# include "arch/pico_linux.h" /* #elif defined ... */
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 10/16 picotcp: switch to Kbuild
In reply to Antony Pavlov--- 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(+)
net/picotcp/.gitignore +1 -0
@@ -22,3 +22,4 @@ cscope.out *.gcov *.gcda *.gcno +*.o.cmd
net/picotcp/Kconfig new file +34 -0
@@ -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
net/picotcp/Makefile new file +30 -0
@@ -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/
net/picotcp/modules/Makefile new file +8 -0
@@ -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
net/picotcp/stack/Makefile new file +7 -0
@@ -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
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 11/16 net: add initial picotcp support
In reply to Antony PavlovThis 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.
--- Makefile | 1 + commands/Kconfig | 4 +++ include/net.h | 37 ++++++++++++++++++++++- include/pico_defines.h | 0 include/stdint.h | 1 + net/Kconfig | 16 ++++++++++ net/Makefile | 3 ++ net/eth.c | 71 +++++++++++++++++++++++++++++++++++++++++++ net/net.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++- net/picotcp.c | 20 +++++++++++++ 10 files changed, 232 insertions(+), 2 deletions(-)
Makefile +1 -0
@@ -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 \
commands/Kconfig +4 -0
@@ -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
include/net.h +36 -1
@@ -24,6 +24,10 @@#include <linux/string.h> /* memcpy */ #include <asm/byteorder.h> /* for nton* / ntoh* stuff */ +#include <pico_stack.h> +#include <pico_socket.h> +#include <pico_ipv4.h> +/* How often do we retry to send packages */ #define PKT_NUM_RETRIES 4
@@ -44,6 +48,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;
@@ -433,6 +438,8 @@ struct net_connection {void *handler;int proto;void *priv; +struct pico_socket *sock; +uint16_t remote_port; };static inline char *net_alloc_packet (void )
@@ -450,10 +457,28 @@ void net_unregister(struct net_connection *con);static inline int net_udp_bind (struct net_connection *con,uint16_t sport) { +if (IS_ENABLED (CONFIG_NET_PICOTCP )) { +union pico_address local_address; +uint16_t localport; + +/* FIXME: use local_address == PICO_IPV4_INADDR_ANY */ +memset (&local_address,0 ,sizeof (union pico_address )); + + localport =ntohs (sport); + +/* FIXME: check pico_socket_bind() return value */ +pico_socket_bind (con->sock, &local_address, &localport); + +return 0 ; + } + con->udp->uh_sport =ntohs (sport);return 0 ; } +#define UDP_PAYLOAD_SIZE (PKTSIZE - sizeof(struct ethernet) - sizeof(struct iphdr) - \ + sizeof(struct udphdr)) +static inline void *net_udp_get_payload (struct net_connection *con) { return con->packet + sizeof(struct ethernet) + sizeof(struct iphdr) +
@@ -475,6 +500,10 @@ static inline uint16_t getudppeerport(struct net_connection *con) {struct udphdr *udp =net_eth_to_udphdr (con->rpacket); +if (IS_ENABLED (CONFIG_NET_PICOTCP )) { +return con->remote_port; + } +return udp->uh_sport; }
@@ -482,7 +511,13 @@ static inline uint16_t getudppeerport(struct net_connection *con)static inline void setudppeerport (struct net_connection *con,uint16_t dport) { - con->udp->uh_dport = dport; +if (IS_ENABLED (CONFIG_NET_LEGACY )) { + con->udp->uh_dport = dport; + }else if (IS_ENABLED (CONFIG_NET_PICOTCP )) { +/* FIXME */ +// pico_socket_connect(npriv->con->sock, &remote_address, dport); + con->sock->remote_port = dport; + } }#endif /* __NET_H__ */
include/pico_defines.h new file +0 -0
include/stdint.h new file +1 -0
@@ -0,0 +1 @@ +/* fake stdint.h for picotcp */
net/Kconfig +16 -0
@@ -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"
@@ -20,10 +32,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
net/Makefile +3 -0
@@ -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
net/eth.c +71 -0
83 lines not on this page · raw message
net/net.c +80 -1
131 lines not on this page · raw message
net/picotcp.c new file +20 -0
@@ -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);
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 12/16 net: picotcp: add test_picotcp command
In reply to Antony PavlovSee original test_ipv4() from picotcp.git/test/unit/unit_ipv4.c.
--- net/Makefile | 2 ++ net/picotcp/Kconfig | 7 ++++ net/picotcp_test_ipv4.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+)
net/Makefile +2 -0
@@ -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
net/picotcp/Kconfig +7 -0
@@ -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
net/picotcp_test_ipv4.c new file +96 -0
96 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 13/16 net: picotcp: add ifconfig command
In reply to Antony Pavlov--- net/Makefile | 1 + net/picotcp/Kconfig | 5 +++ net/picotcp_ifconfig.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+)
net/Makefile +1 -0
@@ -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
net/picotcp/Kconfig +5 -0
@@ -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
net/picotcp_ifconfig.c new file +116 -0
116 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 14/16 net: picotcp: add ping command
In reply to Antony Pavlov--- net/Makefile | 1 + net/picotcp/Kconfig | 5 ++++ net/picotcp_ping.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+)
net/Makefile +1 -0
@@ -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
net/picotcp/Kconfig +5 -0
@@ -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
net/picotcp_ping.c new file +85 -0
85 lines not on this page · raw message
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 15/16 net: picotcp: add route command
In reply to Antony Pavlov--- net/Makefile | 1 + net/picotcp/Kconfig | 5 +++++ net/picotcp_route.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
net/Makefile +1 -0
@@ -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
net/picotcp/Kconfig +5 -0
@@ -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
net/picotcp_route.c new file +36 -0
@@ -0,0 +1,36 @@ +#include <common.h> +#include <command.h> +#include <complete.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
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
RFC v2 16/16 sandbox_defconfig: switch to picotcp
In reply to Antony PavlovPicotcp 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
--- arch/sandbox/configs/sandbox_defconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/sandbox/configs/sandbox_defconfig +5 -3
@@ -36,10 +36,7 @@ CONFIG_CMD_LET=y CONFIG_CMD_MSLEEP=y CONFIG_CMD_READF=y CONFIG_CMD_SLEEP=y -CONFIG_CMD_DHCP=y CONFIG_CMD_HOST=y -CONFIG_CMD_PING=y -CONFIG_CMD_TFTP=y CONFIG_CMD_ECHO_E=y CONFIG_CMD_EDIT=y CONFIG_CMD_MENU=y
@@ -61,8 +58,13 @@ CONFIG_CMD_OFTREE=y CONFIG_CMD_TIME=y CONFIG_CMD_SPD_DECODE=y CONFIG_NET=y +CONFIG_NET_PICOTCP=y CONFIG_NET_NFS=y CONFIG_NET_NETCONSOLE=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
Signature · 7 lines
2.1.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Antony,
Quoted 21 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;
Quoted 8 lines
2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
First of all I applied patches 1-4 to next.
I can't get this version to work. I have done:
# eth0.ethaddr=00:04:9f:01:b5:37
# eth0.ipaddr=192.168.23.170
# eth0.netmask=255.255.0.0
# mount -t tftp 192.168.23.4 /mnt/ # cp mnt/b b T T T T could not open mnt/b: Interrupted system call # picoping 192.168.23.4 ---- Ping timeout!!! PING 1 to 192.168.23.4: Error 1 picoping: I/O error
Anything I have missed?
I noticed that the MAC address is no longer set and the stack no longer checks for a link. I believe picotcp should call eth_send rather than invoking eth->send directly.
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 27 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 24 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is the reason of your 'Ping timeout!!!'
Quoted 14 lines
I can't get this version to work. I have done:
# eth0.ethaddr=00:04:9f:01:b5:37
# eth0.ipaddr=192.168.23.170
# eth0.netmask=255.255.0.0# mount -t tftp 192.168.23.4 /mnt/ # cp mnt/b b T T T T could not open mnt/b: Interrupted system call # picoping 192.168.23.4 ---- Ping timeout!!! PING 1 to 192.168.23.4: Error 1 picoping: I/O error
Quoted 1 line
Anything I have missed?
Please use ifconfig for interface setup. E.g.
ifconfig eth 192.168.23.170 255.255.0.0
I think it is possible to implement network interface setup via eth0.ipaddr and eth0.netmask manipulation (and even sacrifice ifconfig command).
Here is my picotcp test script
#!/bin/sh
SERVER=192.168.100.1
ifconfig eth 192.168.100.2 255.255.255.0
picoping $SERVER
net.nameserver=$SERVER
host barebox.example.com
host www.example.com
mount -t nfs $SERVER:/tftpboot /mnt
ls /mnt
md5sum /mnt/bash
umount /mnt
ls /mnt
mount -t tftp $SERVER /mnt
md5sum /mnt/test
umount /mnt
Quoted 3 lines
I noticed that the MAC address is no longer set and the stack no longer checks for a link. I believe picotcp should call
eth_sendrather than invokingeth->senddirectly.
Hmmm, It looks like I have completely missed any MAC-address manipulation stuff.
I see no means to use eth_send() from picotcp code at the moment.
Just now picotcp "parasitize" on legacy stack: for one phisical network interface there are the picotcp network interface and the legacy network interface at the same time, but only picotcp actualy operates (but some legacy network interface functions are not realized).
The main problem is that barebox has the 'only one network interface is active' conception, but picotcp can handle several active network interfaces at the same time. In this patchseries the 'only one network interface is active' conception is not used, so some commands (dhcp, ifup) do not work.
Picotcp selects necessary network interface for eth->send() invoking after routing. But if I just call eth_send() from picotcp a collision is possible.
E.g. if you have two network interfaces and picotcp want to use the 2nd for packet sending but barebox thinks that the 1st interface is active then eth_send() leads to sending via the 1st one.
I think it is possible to impart current_active_interface property to picotcp-barebox glue code for smooth integration.
I'll try to take into account your notes in the next picotcp integration patchseries;
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 25 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
Quoted 6 lines
Quoted 4 lines
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
First of all I applied patches 1-4 to next.
Sascha!
Please comment patches 5-7!
Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 36 lines · Antony Pavlov
Quoted 33 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 29 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
Quoted 8 lines
Quoted 1 line
First of all I applied patches 1-4 to next.
Sascha!
Please comment patches 5-7!
Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.
From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use net_alloc_packet(). Otherwise this happens:
eth0: Transmit data not aligned: c0416acc!
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 43 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 42 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 25 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
Quoted 6 lines
Quoted 4 lines
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
First of all I applied patches 1-4 to next.
Sascha!
Please comment patches 5-7!
Quoted 8 lines
Quoted 2 lines
Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.
From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use
net_alloc_packet(). Otherwise this happens:eth0: Transmit data not aligned:
c0416acc!
I see only one possibility: fix pico_zalloc() macro definition in net/picotcp/include/arch/pico_barebox.h.
Could you please check it on your hardware?
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 43 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 42 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 25 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
Quoted 6 lines
Quoted 4 lines
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
First of all I applied patches 1-4 to next.
Sascha!
Please comment patches 5-7!
Quoted 9 lines
Quoted 2 lines
Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.
From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use
net_alloc_packet(). Otherwise this happens:eth0: Transmit data not aligned:
c0416acc!
Could you try this patch, please?
net/picotcp/include/arch/pico_barebox.h +10 -1
@@ -45,7 +45,16 @@ static inline void pico_free(void *x) }#else -#define pico_zalloc (x) calloc(x, 1) +#include <xfuncs.h> + +static inline void *xzmemalign (size_t alignment,size_t bytes) +{ +void *ptr =xmemalign (alignment, bytes); +memset (ptr,0 , bytes); +return ptr; +} + +#define pico_zalloc (x) xzmemalign(32, x)#define pico_free (x) free(x)#endif
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 49 lines · Antony Pavlov
Quoted 46 lines · On Mon, 20 Jul 2015 12:45:24 +0200 Sascha Hauer <[email protected]> wrote:
Quoted 44 lines · Antony Pavlov
Quoted 28 lines · On Mon, 20 Jul 2015 09:10:13 +0200 Sascha Hauer <[email protected]> wrote:
Hi Antony,
Quoted 25 lines · Antony Pavlov
I have just published latest picotcp-enabled barebox. Please see my 20150719.picotcp branch in my github barebox repo
(https://github.com/frantony/barebox/tree/20150719.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.07.15 (see http://lists.infradead.org/pipermail/barebox/2015-June/024174.html):
* net: UDP API changed to satisfy the picotcp integration needs;
* nfs, tftp and dns subsystems have no picotcp-related stuff anymore.
* netconsole works on top of picotcp with no additional changes.Here are some notes:
1. just now tftp/nfs file transfer on top of picotcp is slower than
the same transfer on top of legacy network stack;2. there is no $<current network interface> anymore, so dhcp, tftp and ifup commands don't work on top of picotcp. The ifconfig command is used for network interfaces setup.
Quoted 6 lines
Quoted 4 lines
N.B. There is an old patch for dhcp support on top of picotcp
https://github.com/frantony/barebox/commit/94021b6d7bb933cd50b7ea9e2c55725b5c4042053. The picoping command is used insted of traditional ping command.
First of all I applied patches 1-4 to next.
Sascha!
Please comment patches 5-7!
Probably these patches will be changed in the next picotcp integration patchseries version, but your comment on them could be very beneficial.
Quoted 8 lines
Quoted 6 lines
From looking at them they are ok. I haven't found the place where you allocate packets now, but please make sure they are aligned for dma accesses, i.e. use
net_alloc_packet(). Otherwise this happens:eth0: Transmit data not aligned:
c0416acc!Could you try this patch, please?
With this the packets are now sufficiently aligned. When I replace edev->send with eth_send in pico_adapter_send I get a step further. Packets are still sent with the wrong mac address. It uses 00:00:00:0a:0b:0c which is probably some dummy value you introduced somehwere, but the ethernet device is never configured with that value.
Sascha
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox