• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2001-2003 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  */
32 #ifndef __LWIPOPTS_H__
33 #define __LWIPOPTS_H__
34 
35 #include <common/sys_config.h>
36 #include <components/log.h>
37 
38 
39 
40 /**
41  * Loopback demo related options.
42  */
43 #define LWIP_NETIF_LOOPBACK             1
44 #define LWIP_HAVE_LOOPIF                1
45 #define LWIP_NETIF_LOOPBACK_MULTITHREADING       1
46 #define LWIP_LOOPBACK_MAX_PBUFS         8
47 
48 #define TCPIP_THREAD_NAME               "tcp/ip"
49 #ifdef CONFIG_KEYVALUE
50 #define TCPIP_THREAD_STACKSIZE          1024
51 #else
52 #define TCPIP_THREAD_STACKSIZE          512
53 #endif
54 
55 #if CONFIG_LITEOS_M
56 #define TCPIP_THREAD_PRIO               7
57 #else
58 #define TCPIP_THREAD_PRIO               2
59 #endif
60 
61 #define DEFAULT_THREAD_STACKSIZE        200
62 #if CONFIG_LITEOS_M
63 #define DEFAULT_THREAD_PRIO             1
64 #else
65 #define DEFAULT_THREAD_PRIO             8
66 #endif
67 
68 /* Disable lwIP asserts */
69 #define LWIP_NOASSERT			        1
70 
71 #define LWIP_DEBUG                      0
72 #define LWIP_DEBUG_TRACE                0
73 #define SOCKETS_DEBUG                   LWIP_DBG_OFF
74 #define IP_DEBUG                        LWIP_DBG_OFF
75 #define ETHARP_DEBUG                    LWIP_DBG_OFF
76 #define NETIF_DEBUG                     LWIP_DBG_OFF
77 #define PBUF_DEBUG                      LWIP_DBG_OFF
78 #define MEMP_DEBUG                      LWIP_DBG_OFF
79 #define API_LIB_DEBUG                   LWIP_DBG_OFF
80 #define API_MSG_DEBUG                   LWIP_DBG_OFF
81 #define ICMP_DEBUG                      LWIP_DBG_OFF
82 #define IGMP_DEBUG                      LWIP_DBG_OFF
83 #define INET_DEBUG                      LWIP_DBG_OFF
84 #define IP_REASS_DEBUG                  LWIP_DBG_OFF
85 #define RAW_DEBUG                       LWIP_DBG_OFF
86 #define MEM_DEBUG                       LWIP_DBG_OFF
87 #define SYS_DEBUG                       LWIP_DBG_OFF
88 #define TCP_DEBUG                       LWIP_DBG_OFF
89 #define TCP_INPUT_DEBUG                 LWIP_DBG_OFF
90 #define TCP_FR_DEBUG                    LWIP_DBG_OFF
91 #define TCP_RTO_DEBUG                   LWIP_DBG_OFF
92 #define TCP_CWND_DEBUG                  LWIP_DBG_OFF
93 #define TCP_WND_DEBUG                   LWIP_DBG_OFF
94 #define TCP_OUTPUT_DEBUG                LWIP_DBG_OFF
95 #define TCP_RST_DEBUG                   LWIP_DBG_OFF
96 #define TCP_QLEN_DEBUG                  LWIP_DBG_OFF
97 #define UDP_DEBUG                       LWIP_DBG_OFF
98 #define TCPIP_DEBUG                     LWIP_DBG_OFF
99 #define PPP_DEBUG                       LWIP_DBG_OFF
100 #define SLIP_DEBUG                      LWIP_DBG_OFF
101 #define DHCP_DEBUG                      LWIP_DBG_OFF
102 #define AUTOIP_DEBUG                    LWIP_DBG_OFF
103 #define SNMP_MSG_DEBUG                  LWIP_DBG_OFF
104 #define SNMP_MIB_DEBUG                  LWIP_DBG_OFF
105 #define DNS_DEBUG                       LWIP_DBG_OFF
106 #define IP6_DEBUG                       LWIP_DBG_OFF
107 #define MDNS_DEBUG                      LWIP_DBG_OFF
108 
109 //#define LWIP_COMPAT_MUTEX      		    1
110 /**
111  * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain
112  * critical regions during buffer allocation, deallocation and memory
113  * allocation and deallocation.
114  */
115 #define SYS_LIGHTWEIGHT_PROT            1
116 
117 /*
118    ------------------------------------
119    ---------- Memory options ----------
120    ------------------------------------
121 */
122 
123 #define MEM_TRX_DYNAMIC_EN          0
124 
125 /**
126  * MEM_ALIGNMENT: should be set to the alignment of the CPU
127  *    4 byte alignment -> #define MEM_ALIGNMENT 4
128  *    2 byte alignment -> #define MEM_ALIGNMENT 2
129  */
130 #define MEM_ALIGNMENT                   4
131 
132 #define MAX_SOCKETS_TCP 8
133 #define MAX_LISTENING_SOCKETS_TCP 4
134 #define MAX_SOCKETS_UDP 8
135 #define TCP_SND_BUF_COUNT 5
136 
137 /* Value of TCP_SND_BUF_COUNT denotes the number of buffers and is set by
138  * CONFIG option available in the SDK
139  */
140 /* Buffer size needed for TCP: Max. number of TCP sockets * Size of pbuf *
141  * Max. number of TCP sender buffers per socket
142  *
143  * Listening sockets for TCP servers do not require the same amount buffer
144  * space. Hence do not consider these sockets for memory computation
145  */
146 #define TCP_MEM_SIZE     (MAX_SOCKETS_TCP * \
147 							PBUF_POOL_BUFSIZE * (TCP_SND_BUF/TCP_MSS))
148 
149 /* Buffer size needed for UDP: Max. number of UDP sockets * Size of pbuf
150  */
151 #define UDP_MEM_SIZE (MAX_SOCKETS_UDP * PBUF_POOL_BUFSIZE)
152 
153 /**
154  * MEM_SIZE: the size of the heap memory. If the application will send
155  * a lot of data that needs to be copied, this should be set high.
156  */
157 #if (MEM_TRX_DYNAMIC_EN)
158 #define MEM_SIZE (60*1024)
159 #define MEM_MAX_TX_SIZE (MEM_SIZE*5)/6
160 #define MEM_MAX_RX_SIZE (MEM_SIZE*3)/4
161 #else
162 #if (CONFIG_LWIP_MEM_REDUCE)
163 #define MEM_SIZE (32*1024)
164 #else
165 #define MEM_SIZE (48*1024)
166 #endif //CONFIG_LWIP_MEM_REDUCE
167 #endif //MEM_TRX_DYNAMIC_EN
168 
169 
170 /*
171    ------------------------------------------------
172    ---------- Internal Memory Pool Sizes ----------
173    ------------------------------------------------
174 */
175 /**
176  * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
177  * If the application sends a lot of data out of ROM (or other static memory),
178  * this should be set high.
179  */
180 #define MEMP_NUM_PBUF                   10
181 
182 /**
183  * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections.
184  * (requires the LWIP_TCP option)
185  */
186 #define MEMP_NUM_TCP_PCB                MAX_SOCKETS_TCP
187 
188 #define MEMP_NUM_TCP_PCB_LISTEN         MAX_LISTENING_SOCKETS_TCP
189 
190 /**
191  * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
192  * (requires the LWIP_TCP option)
193  */
194 //#define MEMP_NUM_TCP_SEG                12
195 
196 /**
197  * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
198  * for incoming packets.
199  * (only needed if you use tcpip.c)
200  */
201 
202 #define MEMP_NUM_TCPIP_MSG_INPKT        16
203 
204 /**
205  * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts.
206  * (requires NO_SYS==0)
207  */
208 #define MEMP_NUM_SYS_TIMEOUT            12
209 
210 /**
211  * MEMP_NUM_NETBUF: the number of struct netbufs.
212  * (only needed if you use the sequential API, like api_lib.c)
213  */
214 #if (MEM_TRX_DYNAMIC_EN)
215 #define MEMP_NUM_NETBUF                 32
216 #else
217 #define MEMP_NUM_NETBUF                 16
218 #endif
219 /**
220  * MEMP_NUM_NETCONN: the number of struct netconns.
221  * (only needed if you use the sequential API, like api_lib.c)
222  *
223  * This number corresponds to the maximum number of active sockets at any
224  * given point in time. This number must be sum of max. TCP sockets, max. TCP
225  * sockets used for listening, and max. number of UDP sockets
226  */
227 #define MEMP_NUM_NETCONN	(MAX_SOCKETS_TCP + \
228 	MAX_LISTENING_SOCKETS_TCP + MAX_SOCKETS_UDP)
229 
230 
231 
232 /**
233  * PBUF_POOL_SIZE: the number of buffers in the pbuf pool.
234  */
235 #if (MEM_TRX_DYNAMIC_EN)
236 #define PBUF_POOL_SIZE                  3
237 #else
238 #define PBUF_POOL_SIZE                  20
239 #endif
240 
241 /*
242    ----------------------------------
243    ---------- Pbuf options ----------
244    ----------------------------------
245 */
246 
247 /**
248  * PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. The default is
249  * designed to accomodate single full size TCP frame in one pbuf, including
250  * TCP_MSS, IP header, and link header.
251  */
252 #if CONFIG_WIFI6_CODE_STACK
253 #define PBUF_LINK_ENCAPSULATION_HLEN    CONFIG_MSDU_RESV_HEAD_LENGTH
254 #define PBUF_POOL_BUFSIZE               (1580 + PBUF_LINK_ENCAPSULATION_HLEN)
255 #else
256 #define PBUF_POOL_BUFSIZE               1580
257 #endif
258 
259 
260 /*
261    ---------------------------------
262    ---------- RAW options ----------
263    ---------------------------------
264 */
265 /**
266  * LWIP_RAW==1: Enable application layer to hook into the IP layer itself.
267  */
268 #define LWIP_RAW                        1
269 #ifdef CONFIG_IPV6
270 #define LWIP_IPV6                        1
271 #endif
272 
273 /* Enable IPv4 Auto IP	*/
274 #ifdef CONFIG_AUTOIP
275 #define LWIP_AUTOIP                     1
276 #define LWIP_DHCP_AUTOIP_COOP           1
277 #define LWIP_DHCP_AUTOIP_COOP_TRIES		5
278 #endif
279 
280 
281 /* Enable MDNS	*/
282 #ifdef CONFIG_MDNS
283 #define LWIP_MDNS_RESPONDER             1
284 #define LWIP_NUM_NETIF_CLIENT_DATA      (LWIP_MDNS_RESPONDER)
285 #endif
286 
287 
288 
289 
290 /*
291    ------------------------------------
292    ---------- Socket options ----------
293    ------------------------------------
294 */
295 /**
296  * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
297  */
298 #define LWIP_SOCKET                     1
299 #define LWIP_NETIF_API			1
300 
301 /**
302  * LWIP_RECV_CB==1: Enable callback when a socket receives data.
303  */
304 #define LWIP_RECV_CB                1
305 /**
306  * SO_REUSE==1: Enable SO_REUSEADDR option.
307  */
308 #define SO_REUSE                        1
309 #define SO_REUSE_RXTOALL 				1
310 
311 /**
312  * Enable TCP_KEEPALIVE
313  */
314 #define LWIP_TCP_KEEPALIVE              1
315 
316 /*
317    ----------------------------------------
318    ---------- Statistics options ----------
319    ----------------------------------------
320 */
321 /**
322  * LWIP_STATS==1: Enable statistics collection in lwip_stats.
323  */
324 #define LWIP_STATS                      1
325 
326 /**
327  * LWIP_STATS_DISPLAY==1: Compile in the statistics output functions.
328  */
329 #define LWIP_STATS_DISPLAY              1
330 
331 /*
332    ----------------------------------
333    ---------- DHCP options ----------
334    ----------------------------------
335 */
336 /**
337  * LWIP_DHCP==1: Enable DHCP module.
338  */
339 #define LWIP_DHCP                       1
340 #define LWIP_NETIF_STATUS_CALLBACK      1
341 
342 /**
343  * DNS related options, revisit later to fine tune.
344  */
345 #define LWIP_DNS                        1
346 #define DNS_TABLE_SIZE                  2  // number of table entries, default 4
347 //#define DNS_MAX_NAME_LENGTH           64  // max. name length, default 256
348 #define DNS_MAX_SERVERS                 2  // number of DNS servers, default 2
349 #define DNS_DOES_NAME_CHECK             1  // compare received name with given,def 0
350 #define DNS_MSG_SIZE                    512
351 #define MDNS_MSG_SIZE                   512
352 #define MDNS_TABLE_SIZE                 1  // number of mDNS table entries
353 #define MDNS_MAX_SERVERS                1  // number of mDNS multicast addresses
354 /* TODO: Number of active UDP PCBs is equal to number of active UDP sockets plus
355  * two. Need to find the users of these 2 PCBs
356  */
357 #define MEMP_NUM_UDP_PCB		(MAX_SOCKETS_UDP + 2)
358 /* NOTE: some times the socket() call for SOCK_DGRAM might fail if you dont
359  * have enough MEMP_NUM_UDP_PCB */
360 
361 /*
362    ----------------------------------
363    ---------- IGMP options ----------
364    ----------------------------------
365 */
366 /**
367  * LWIP_IGMP==1: Turn on IGMP module.
368  */
369 #define LWIP_IGMP                       1
370 
371 /**
372  * LWIP_SO_CONTIMEO==1: Enable send timeout for sockets/netconns and
373  * SO_CONTIMEO processing.
374  */
375 #define LWIP_SO_CONTIMEO                1
376 
377 /**
378  * LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
379  * SO_SNDTIMEO processing.
380  */
381 #define LWIP_SO_SNDTIMEO                1
382 
383 /**
384  * LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
385  * SO_RCVTIMEO processing.
386  */
387 #define LWIP_SO_RCVTIMEO                1
388 #define LWIP_SO_SNDTIMEO                1
389 /**
390  * TCP_LISTEN_BACKLOG==1: Handle backlog connections.
391  */
392 #define TCP_LISTEN_BACKLOG		        1
393 #define LWIP_PROVIDE_ERRNO		        1
394 
395 #include <lwip/errno.h>
396 #define ERRNO				            1
397 
398 //#define LWIP_SNMP 1
399 
400 
401 /*
402    ------------------------------------------------
403    ---------- Network Interfaces options ----------
404    ------------------------------------------------
405 */
406 /**
407  * LWIP_NETIF_HOSTNAME==1: use DHCP_OPTION_HOSTNAME with netif's hostname
408  * field.
409  */
410 #define LWIP_NETIF_HOSTNAME             1
411 
412 
413 /*
414 The STM32F107 allows computing and verifying the IP, UDP, TCP and ICMP checksums by hardware:
415  - To use this feature let the following define uncommented.
416  - To disable it and process by CPU comment the  the checksum.
417 */
418 //#define CHECKSUM_BY_HARDWARE
419 
420 
421 #ifdef CHECKSUM_BY_HARDWARE
422   /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/
423   #define CHECKSUM_GEN_IP                 0
424   /* CHECKSUM_GEN_UDP==0: Generate checksums by hardware for outgoing UDP packets.*/
425   #define CHECKSUM_GEN_UDP                0
426   /* CHECKSUM_GEN_TCP==0: Generate checksums by hardware for outgoing TCP packets.*/
427   #define CHECKSUM_GEN_TCP                0
428   /* CHECKSUM_CHECK_IP==0: Check checksums by hardware for incoming IP packets.*/
429   #define CHECKSUM_CHECK_IP               0
430   /* CHECKSUM_CHECK_UDP==0: Check checksums by hardware for incoming UDP packets.*/
431   #define CHECKSUM_CHECK_UDP              0
432   /* CHECKSUM_CHECK_TCP==0: Check checksums by hardware for incoming TCP packets.*/
433   #define CHECKSUM_CHECK_TCP              0
434 #else
435   /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/
436   #define CHECKSUM_GEN_IP                 1
437   /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/
438   #define CHECKSUM_GEN_UDP                1
439   /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/
440   #define CHECKSUM_GEN_TCP                1
441   /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/
442   #define CHECKSUM_CHECK_IP               1
443   /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/
444   #define CHECKSUM_CHECK_UDP              1
445   /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/
446   #define CHECKSUM_CHECK_TCP              1
447 #endif
448 
449 /**
450  * TCP_RESOURCE_FAIL_RETRY_LIMIT: limit for retrying sending of tcp segment
451  * on resource failure error returned by driver.
452  */
453 #define TCP_RESOURCE_FAIL_RETRY_LIMIT     50
454 
455 //#ifdef CONFIG_ENABLE_MXCHIP
456 /* save memory */
457 #if (CONFIG_LWIP_MEM_REDUCE)
458 #define TCP_MSS                 (1500 - 40)
459 /* TCP receive window. */
460 #define TCP_WND                 (10 * TCP_MSS)
461 /* TCP sender buffer space (bytes). */
462 #define TCP_SND_BUF             (10*TCP_MSS)
463 
464 #define TCP_SND_QUEUELEN        (20)
465 #else
466 #define TCP_MSS                 (1500 - 40)
467 /* TCP receive window. */
468 #define TCP_WND                 (10*TCP_MSS)
469 /* TCP sender buffer space (bytes). */
470 #define TCP_SND_BUF             (10*TCP_MSS)
471 
472 #define TCP_SND_QUEUELEN        (20)
473 #endif
474 
475 /* ARP before DHCP causes multi-second delay  - turn it off */
476 #define DHCP_DOES_ARP_CHECK            (0)
477 
478 #define TCP_MAX_ACCEPT_CONN 5
479 #define MEMP_NUM_TCP_SEG               (TCP_SND_QUEUELEN*2)
480 
481 #define IP_REASS_MAX_PBUFS              0
482 #define IP_REASSEMBLY                   0
483 #define IP_REASS_MAX_PBUFS              0
484 #define IP_REASSEMBLY                   0
485 #define MEMP_NUM_REASSDATA              0
486 #define IP_FRAG                         0
487 
488 #define MEM_LIBC_MALLOC                (0)
489 
490 #if (CONFIG_LWIP_MEM_REDUCE)
491 #define DEFAULT_UDP_RECVMBOX_SIZE       16 //each udp socket max buffer 3 packets.
492 #else
493 #define DEFAULT_UDP_RECVMBOX_SIZE       16 //each udp socket max buffer 16 packets.
494 #endif
495 
496 #define MEMP_MEM_MALLOC (0)
497 #define TCP_MSL (TCP_TMR_INTERVAL)
498 
499 #define LWIP_COMPAT_MUTEX_ALLOWED       (1)
500 
501 #define MEMP_STATS                       1
502 #define MEM_STATS                        1
503 
504 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
505 
506 #define ETHARP_SUPPORT_STATIC_ENTRIES   1
507 
508 #define LWIP_RIPPLE20                   1
509 
510 /* Beken specific LWIP options */
511 #define BK_DHCP                         1
512 
513 #define LWIP_TAG "lwip"
514 #define LWIP_LOGI(...) BK_LOGI(LWIP_TAG, ##__VA_ARGS__)
515 #define LWIP_LOGW(...) BK_LOGW(LWIP_TAG, ##__VA_ARGS__)
516 #define LWIP_LOGE(...) BK_LOGE(LWIP_TAG, ##__VA_ARGS__)
517 #define LWIP_LOGD(...) BK_LOGD(LWIP_TAG, ##__VA_ARGS__)
518 #if 0
519 #define LWIP_HOOK_FILENAME              "lwip_hooks.h"
520 #define LWIP_HOOK_IP4_ROUTE_SRC         ip4_route_src_hook
521 #endif
522 #define BK_IP4_ROUTE                    1
523 #define BK_DHCPS_DNS                    1
524 
525 #endif /* __LWIPOPTS_H__ */
526 
527