Skip to content

Commit 110f7bc

Browse files
committedApr 25, 2015
runtime: saner lwipopts
1 parent 8f5f428 commit 110f7bc

File tree

1 file changed

+98
-130
lines changed

1 file changed

+98
-130
lines changed
 

Diff for: ‎soc/runtime/liblwip/lwipopts.h

+98-130
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,109 @@
1-
// This file is Copyright (c) 2015 Florent Kermarrec <florent@enjoy-digital.fr>
2-
// LiteETH lwIP port for ARTIQ
3-
// License: BSD
1+
/*
2+
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* 3. The name of the author may not be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17+
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19+
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21+
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25+
* OF SUCH DAMAGE.
26+
*
27+
* This file is part of the lwIP TCP/IP stack.
28+
*
29+
* Author: Adam Dunkels <adam@sics.se>
30+
*
31+
*/
432

533
#ifndef __LWIPOPTS_H__
634
#define __LWIPOPTS_H__
735

8-
//#define LWIP_DEBUG
9-
#include <lwip/debug.h>
10-
11-
/*----------------------------General options ------------------------------ */
1236
#define NO_SYS 1
1337
#define LWIP_NETCONN 0
1438
#define LWIP_SOCKET 0
1539
#define LWIP_IPV6 0
1640

17-
/* ------------------------ Memory options -------------------------------- */
41+
#define LWIP_CALLBACK_API 1
42+
43+
/* -------- TCP Timer Intervals ------- */
44+
#define TCP_TMR_INTERVAL 1 /* The TCP timer interval in
45+
milliseconds. */
46+
47+
#define TCP_FAST_INTERVAL 2 /* the fine grained timeout in
48+
milliseconds */
49+
50+
#define TCP_SLOW_INTERVAL 5 /* the coarse grained timeout in
51+
milliseconds */
52+
53+
/* ---------- Memory options ---------- */
1854
/* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
1955
lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
2056
byte alignment -> define MEM_ALIGNMENT to 2. */
21-
#define MEM_ALIGNMENT 4 /* MUST BE 4 */
57+
#define MEM_ALIGNMENT 4
2258

2359
/* MEM_SIZE: the size of the heap memory. If the application will send
2460
a lot of data that needs to be copied, this should be set high. */
25-
#define MEM_SIZE 16000
61+
#define MEM_SIZE 32 * 1024
2662

2763
/* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
2864
sends a lot of data out of ROM (or other static memory), this
2965
should be set high. */
30-
#define MEMP_NUM_PBUF 20
66+
#define MEMP_NUM_PBUF 64
3167
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
3268
per active UDP "connection". */
33-
#define MEMP_NUM_UDP_PCB 4
69+
#define MEMP_NUM_UDP_PCB 1
3470
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
3571
connections. */
36-
#define MEMP_NUM_TCP_PCB 10
72+
#define MEMP_NUM_TCP_PCB 8
3773
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
3874
connections. */
39-
#define MEMP_NUM_TCP_PCB_LISTEN 8
75+
#define MEMP_NUM_TCP_PCB_LISTEN 16
4076
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
4177
segments. */
42-
#define MEMP_NUM_TCP_SEG 8
43-
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
44-
timeouts. */
45-
#define MEMP_NUM_SYS_TIMEOUT 3
78+
#define MEMP_NUM_TCP_SEG 255
4679

4780
/* The following four are used only with the sequential API and can be
4881
set to 0 if the application only will use the raw API. */
4982
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
50-
//#define MEMP_NUM_NETBUF 4
83+
#define MEMP_NUM_NETBUF 0
5184
/* MEMP_NUM_NETCONN: the number of struct netconns. */
52-
//#define MEMP_NUM_NETCONN 4
53-
54-
/* These two control is reclaimer functions should be compiled
55-
in. Should always be turned on (1). */
56-
#define MEM_RECLAIM 1
57-
#define MEMP_RECLAIM 1
85+
#define MEMP_NUM_NETCONN 0
86+
/* MEMP_NUM_TCPIP_MSG: the number of struct tcpip_msg, which is used
87+
for sequential API communication and incoming packets. Used in
88+
src/api/tcpip.c. */
89+
#define MEMP_NUM_TCPIP_MSG_API 0
90+
#define MEMP_NUM_TCPIP_MSG_INPKT 0
91+
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
92+
timeouts. */
93+
#define MEMP_NUM_SYS_TIMEOUT 5
5894

5995
/* ---------- Pbuf options ---------- */
6096
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
61-
#define PBUF_POOL_SIZE 4
97+
#define PBUF_POOL_SIZE 512
6298

6399
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
64-
#define PBUF_POOL_BUFSIZE 1024
100+
#define PBUF_POOL_BUFSIZE 1536
65101

66102
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
67103
link level header. */
68104
#define PBUF_LINK_HLEN 16
69105

70-
/* ------------------------ TCP options ----------------------------------- */
106+
/* ---------- TCP options ---------- */
71107
#define LWIP_TCP 1
72108
#define TCP_TTL 255
73109

@@ -76,138 +112,70 @@ a lot of data that needs to be copied, this should be set high. */
76112
#define TCP_QUEUE_OOSEQ 1
77113

78114
/* TCP Maximum segment size. */
79-
#define TCP_MSS 256
115+
#define TCP_MSS 1476
80116

81117
/* TCP sender buffer space (bytes). */
82-
#define TCP_SND_BUF 512
118+
#define TCP_SND_BUF 32 * 1024
83119

84120
/* TCP sender buffer space (pbufs). This must be at least = 2 *
85121
TCP_SND_BUF/TCP_MSS for things to work. */
86-
#define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS
122+
#define TCP_SND_QUEUELEN 2 * TCP_SND_BUF/TCP_MSS
87123

88124
/* TCP receive window. */
89-
#define TCP_WND 256
125+
#define TCP_WND 16 * 1024
90126

91127
/* Maximum number of retransmissions of data segments. */
92128
#define TCP_MAXRTX 12
93129

94130
/* Maximum number of retransmissions of SYN segments. */
95131
#define TCP_SYNMAXRTX 4
96132

97-
/* ------------------------ ARP options ----------------------------------- */
98-
#define LWIP_ARP 1
99-
#define ARP_TABLE_SIZE 10
100-
#define ARP_QUEUEING 1
133+
/* ---------- ARP options ---------- */
134+
#define ARP_TABLE_SIZE 10
135+
#define ARP_QUEUEING 1
101136

102-
/* ------------------------ IP options ------------------------------------ */
137+
/* ---------- IP options ---------- */
103138
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
104139
IP packets across network interfaces. If you are going to run lwIP
105140
on a device with only one network interface, define this to 0. */
106141
#define IP_FORWARD 0
107142

108143
/* If defined to 1, IP options are allowed (but not parsed). If
109144
defined to 0, all packets with IP options are dropped. */
110-
#define IP_OPTIONS 0 /* set it to 1 to allow IP options in hdr */
111-
#define IP_REASSEMBLY 0 /* set it to 1 to enable tcp/ip reassembly */
112-
#define IP_FRAG 0 /* Outgoing fragmentation of IP packets occurs
113-
* when the packet-size exceeds the path maximum
114-
* packet-size (path MTU). To avoid fragmentation,
115-
* don't allow application OR lwIP to generate packets larger
116-
* than anticipated path maximum transmission unit.
117-
*
118-
* For TCP, setting TCP_MSS to much less than anticipated
119-
* path MTU avoids frag/defrag. For UDP it depends on app
120-
* and path MTU. For ping (ICMP), with large payload,
121-
* frag/reass is required. Some network stacks have
122-
* path MTU discovery capability but not sure if LwIP
123-
* supports it
124-
*/
125-
#define LWIP_RAW 1 /* set it to 1 to enable raw support */
126-
127-
/* ------------------------ ICMP options ---------------------------------- */
145+
#define IP_OPTIONS 1
146+
147+
/* ---------- ICMP options ---------- */
128148
#define ICMP_TTL 255
129149

130-
/* ------------------------ DHCP options ---------------------------------- */
150+
151+
/* ---------- DHCP options ---------- */
131152
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
132153
interfaces. DHCP is not implemented in lwIP 0.5.1, however, so
133154
turning this on does currently not work. */
134155
#define LWIP_DHCP 0
135156

136157
/* 1 if you want to do an ARP check on the offered address
137158
(recommended). */
138-
//#define DHCP_DOES_ARP_CHECK 1
139-
140-
/* ------------------------ UDP options ----------------------------------- */
141-
#define LWIP_UDP 1 /* set it to 1 to enable UDP */
142-
#define UDP_TTL 255 /* time to live for udp */
143-
#define CHECKSUM_GEN_UDP 0 /* don't generate UDP chksum, if UDP enabled*/
144-
#define CHECKSUM_CHECK_UDP 0 /* check chksum in rx UDP pkts if enabled */
145-
146-
#define LWIP_STATS 0
147-
#define LWIP_COMPAT_SOCKETS 0
148-
149-
/* Override the default dynamic memory alloc functions (malloc copy)*/
150-
//#include "memmgr.h"
151-
152-
//#define mem_init()
153-
//#define mem_free memmgr_free
154-
//#define mem_malloc memmgr_alloc
155-
//#define mem_calloc(c, n) memmgr_alloc((c) * (n))
156-
//#define mem_realloc(p, sz) (p)
157-
158-
#ifdef LWIP_DEBUG
159-
/*
160-
* for a list of options for the flags, please refer to
161-
* lwip/src/include/lwip/debug.h
162-
******************NOTE********************************
163-
*
164-
* TO TURN OFF A SPECIFIC DEBUG SOURCE, SET THE VALUE TO
165-
* DBG_OFF
166-
*
167-
* DO NOT MODIFY DBG_TYPES_ON OR DBG_MIN_LEVEL UNLESS YOU
168-
* ARE AWARE WHAT YOU'RE DOING!!
169-
*
170-
*/
171-
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
172-
#define DBG_TYPES_ON LWIP_DBG_TRACE
173-
174-
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
175-
#define ETHARP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
176-
#define NETIF_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
177-
#define PBUF_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
178-
#define API_LIB_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
179-
#define API_MSG_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
180-
#define SOCKETS_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
181-
#define ICMP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
182-
#define INET_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
183-
#define IP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
184-
#define IP_REASS_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
185-
#define RAW_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
186-
#define MEM_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
187-
#define MEMP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
188-
#define SYS_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
189-
#define TCP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
190-
#define TCP_INPUT_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
191-
#define TCP_FR_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
192-
#define TCP_RTO_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
193-
#define TCP_CWND_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
194-
#define TCP_WND_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
195-
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
196-
#define TCP_RST_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
197-
#define TCP_QLEN_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
198-
#define UDP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
199-
#define TCPIP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
200-
#define PPP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
201-
#define SLIP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
202-
#define DHCP_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
203-
#define TIMERS_DEBUG LWIP_DBG_ON|LWIP_DBG_TRACE
204-
205-
/* APPLICATION DEBUGGING */
206-
/* #define HTTPD_DEBUG (1) */
207-
#endif
208-
209-
210-
/* Perform DHCP */
211-
/*#define LWIP_DHCP (1)*/
159+
#define DHCP_DOES_ARP_CHECK 0
160+
161+
/* ---------- UDP options ---------- */
162+
#define LWIP_UDP 0
163+
#define UDP_TTL 255
164+
165+
166+
/* ---------- Statistics options ---------- */
167+
/*#define STATS*/
168+
169+
#ifdef STATS
170+
#define LINK_STATS
171+
#define IP_STATS
172+
#define ICMP_STATS
173+
#define UDP_STATS
174+
#define TCP_STATS
175+
#define MEM_STATS
176+
#define MEMP_STATS
177+
#define PBUF_STATS
178+
#define SYS_STATS
179+
#endif /* STATS */
212180

213181
#endif /* __LWIPOPTS_H__ */

0 commit comments

Comments
 (0)
Please sign in to comment.