PS2SDK
PS2 Homebrew Libraries
lwipopts.h
1 /* If changes are made to this file, please update the defined
2  values at the bottom of common/include/tcpip.h too. */
3 
4 #ifndef __LWIPOPTS_H__
5 #define __LWIPOPTS_H__
6 
7 #define LWIP_TIMEVAL_PRIVATE 0
8 
9 /* ---------- Thread options ---------- */
15 #define DEFAULT_THREAD_STACKSIZE 0x1000
16 
22 #define DEFAULT_THREAD_PRIO 0x58
23 
29 #define TCPIP_THREAD_STACKSIZE DEFAULT_THREAD_STACKSIZE
30 
36 #define TCPIP_THREAD_PRIO DEFAULT_THREAD_PRIO
37 
38 /*
39  ------------------------------------
40  ---------- Memory options ----------
41  ------------------------------------
42 */
53 #define MEM_LIBC_MALLOC 1
54 
55 /* MEM_ALIGNMENT: must equal the alignment libc's malloc returns,
56  because pbuf_alloc(PBUF_RAM) computes
57  payload = LWIP_MEM_ALIGN(p + SIZEOF_STRUCT_PBUF + offset)
58  inside an allocation sized assuming p is already MEM_ALIGNMENT-
59  aligned. If MEM_ALIGNMENT > newlib's alignment the payload pointer
60  overruns the chunk and corrupts the next-chunk header on the
61  freelist (TLB misses inside _malloc_r / _free_r).
62 
63  16 is the contract baked into the toolchain configuration. See
64  newlib/newlib/configure.host:
65 
66  mips64r5900*)
67  machine_dir=r5900
68  newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=16"
69  ;;
70 
71  so for the mips64r5900el-ps2-elf target newlib is built with
72  -DMALLOC_ALIGNMENT=16, which sets _mallocr.c's MALLOC_ALIGNMENT
73  directly (overriding the SIZE_SZ-derived default of 8). 16 is also
74  what samples/malloc_stress observes empirically.
75 
76  The historical value here was 64 with a comment about "the EE cache
77  design" (SP193). That was over-cautious: PBUF_POOL pbufs (the only
78  ones touched by IOP->EE DMA + cache invalidate) come from memp's
79  static pools and are always 64-byte aligned regardless of
80  MEM_ALIGNMENT; PBUF_RAM pbufs (TX, ARP, DNS, ...) only see DMA
81  writeback, where misalignment harmlessly over-flushes extra cache
82  lines. The IOP-side lwipopts has used MEM_ALIGNMENT=4 forever for
83  the same reason. */
84 #define MEM_ALIGNMENT 16
85 
90 /* SP193: setting this too low may cause tcp_write() to fail when it tries to allocate from PBUF_RAM!
91  Up to TCP_SND_BUF * 2 segments may be transmitted at once, thanks to Nagle and Delayed Ack. */
92 #define MEM_SIZE (TCP_SND_BUF * 2)
93 
94 /*
95  ------------------------------------------------
96  ---------- Internal Memory Pool Sizes ----------
97  ------------------------------------------------
98 */
103 #define MEMP_NUM_NETCONN (MEMP_NUM_TCP_PCB+MEMP_NUM_UDP_PCB)
104 
108 //SP193: should be at least ((TCP_WND/PBUF_POOL_BUFSIZE)+1). But that is too small to accommodate data not accepted by the application layer and multiple connections.
109 //NETMAN will also always have PBUFs reserved for incoming frames (currently 64).
110 #define PBUF_POOL_SIZE 128
111 
119 #define MEMP_NUM_TCPIP_MSG_INPKT 50
120 
126 //SP193: this should be around the size of MEM_SIZE (in PBUFs), to prevent transmissions from being potentially being dropped.
127 #define MEMP_NUM_TCPIP_MSG_API 50
128 
133 #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
134 
143 #define LWIP_TCPIP_CORE_LOCKING 1
144 
150 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
151 
152 /*
153  ---------------------------------
154  ---------- TCP options ----------
155  ---------------------------------
156 */
157 /* TCP Maximum segment size. */
158 #define TCP_MSS 1460
159 
160 /* TCP sender buffer space (bytes). */
161 #define TCP_SND_BUF (TCP_MSS*32)
162 
163 /* TCP receive window. */
164 #define TCP_WND 65535
165 
166 /* ---------- DHCP options ---------- */
167 #ifdef PS2IP_DHCP
168 
171 #define LWIP_DHCP 1
172 #endif
173 
174 /* LWIP_DHCP_DOES_ACD_CHECK / LWIP_ACD left at upstream defaults (=1 when
175  * LWIP_DHCP=1) so the RFC 5227 Address Conflict Detection probe runs on
176  * any DHCP-offered IP. EE applications run on user home networks where
177  * IP collisions are a real (if uncommon) failure mode; the few KB of
178  * code and ~1-2 s extra DHCP-bind delay are worth the robustness. The
179  * IOP lwIP build forces both off because ps2link runs in controlled
180  * bench environments where the IRX size + tick savings matter more. */
181 
182 /*
183  ----------------------------------
184  ---------- DNS options -----------
185  ----------------------------------
186 */
191 #ifdef PS2IP_DNS
192 #define LWIP_DNS 1
193 #endif
194 
195 /* ---------- Statistics options ---------- */
199 #define LWIP_STATS 0
200 
201 /*
202  --------------------------------------
203  ---------- Checksum options ----------
204  --------------------------------------
205 */
206 //Rely on the Ethernet checksums to reduce the number of checksum compuations. If you require any of these, re-enable them.
210 #define CHECKSUM_CHECK_IP 0
211 
215 #define CHECKSUM_CHECK_UDP 0
216 
220 #define CHECKSUM_CHECK_TCP 0
221 
225 #define CHECKSUM_CHECK_ICMP 0
226 
230 #define CHECKSUM_CHECK_ICMP6 0
231 
236 #define LWIP_CHECKSUM_ON_COPY 1
237 
238 /*
239  ------------------------------------
240  ---------- Socket options ----------
241  ------------------------------------
242 */
248 #define LWIP_POSIX_SOCKETS_IO_NAMES 0
249 
250 /*
251  ----------------------------------
252  ---------- DNS options -----------
253  ----------------------------------
254 */
259 #define LWIP_DNS_SECURE 0
260 
261 /*
262  ------------------------------------------------
263  ---------- Network Interfaces options ----------
264  ------------------------------------------------
265 */
275 #define LWIP_NETIF_TX_SINGLE_PBUF 1
276 
277 #endif /* __LWIPOPTS_H__ */