Skip to content

Commit b516503

Browse files
author
Colin Hogben
committed
lwip: Expose principal socket limits as configuration parameters.
Allow the limits on numbers of sockets to be changed via the configuration system. The help texts show the RAM penalty from increasing each value.
1 parent 55485ae commit b516503

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,36 +105,52 @@
105105

106106
#define LWIP_RAM_HEAP_POINTER lwip_ram_heap
107107

108+
// Number of pool pbufs.
109+
// Each requires 684 bytes of RAM.
108110
#ifndef PBUF_POOL_SIZE
109-
/// Each requires 684 bytes of RAM.
110111
#define PBUF_POOL_SIZE 5
111112
#endif
112-
#ifndef MEMP_NUM_TCP_PCB_LISTEN
113-
/// One is needed for each TCPServer.
114-
/// Each requires 72 bytes of RAM.
113+
114+
// One tcp_pcb_listen is needed for each TCPServer.
115+
// Each requires 72 bytes of RAM.
116+
#ifdef MBED_CONF_LWIP_TCP_SERVER_MAX
117+
#define MEMP_NUM_TCP_PCB_LISTEN MBED_CONF_LWIP_TCP_SERVER_MAX
118+
#else
115119
#define MEMP_NUM_TCP_PCB_LISTEN 4
116120
#endif
117-
#ifndef MEMP_NUM_TCP_PCB
118-
/// One is needed for each TCPSocket.
119-
/// Each requires 196 bytes of RAM.
121+
122+
// One is tcp_pcb needed for each TCPSocket.
123+
// Each requires 196 bytes of RAM.
124+
#ifdef MBED_CONF_LWIP_TCP_SOCKET_MAX
125+
#define MEMP_NUM_TCP_PCB MBED_CONF_LWIP_TCP_SOCKET_MAX
126+
#else
120127
#define MEMP_NUM_TCP_PCB 4
121128
#endif
122-
#ifndef MEMP_NUM_UDP_PCB
123-
/// One is needed for each UDPSocket.
124-
/// Each requires 84 bytes of RAM (rounded to multiple of 512).
129+
130+
// One udp_pcb is needed for each UDPSocket.
131+
// Each requires 84 bytes of RAM (total rounded to multiple of 512).
132+
#ifdef MBED_CONF_LWIP_UDP_SOCKET_MAX
133+
#define MEMP_NUM_UDP_PCB MBED_CONF_LWIP_UDP_SOCKET_MAX
134+
#else
125135
#define MEMP_NUM_UDP_PCB 4
126136
#endif
137+
138+
// Number of non-pool pbufs.
139+
// Each requires 92 bytes of RAM.
127140
#ifndef MEMP_NUM_PBUF
128-
/// Each requires 92 bytes of RAM.
129141
#define MEMP_NUM_PBUF 8
130142
#endif
143+
144+
// Each netbuf requires 64 bytes of RAM.
131145
#ifndef MEMP_NUM_NETBUF
132-
/// Each requires 64 bytes of RAM.
133146
#define MEMP_NUM_NETBUF 8
134147
#endif
135-
#ifndef MEMP_NUM_NETCONN
136-
/// One netconn is needed for each UDPSocket, TCPSocket or TCPServer.
137-
/// Each requires 236 bytes of RAM (rounded to multiple of 512).
148+
149+
// One netconn is needed for each UDPSocket, TCPSocket or TCPServer.
150+
// Each requires 236 bytes of RAM (total rounded to multiple of 512).
151+
#ifdef MBED_CONF_LWIP_SOCKET_MAX
152+
#define MEMP_NUM_NETCONN MBED_CONF_LWIP_SOCKET_MAX
153+
#else
138154
#define MEMP_NUM_NETCONN 4
139155
#endif
140156

features/FEATURE_LWIP/lwip-interface/mbed_lib.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
"addr-timeout": {
1717
"help": "On dual stack system how long to wait preferred stack's address in seconds",
1818
"value": 5
19+
},
20+
"socket-max": {
21+
"help": "Maximum number of open TCPServer, TCPSocket and UDPSocket instances allowed, including one used internally for DNS. Each requires 236 bytes of pre-allocated RAM",
22+
"value": 4
23+
},
24+
"tcp-server-max": {
25+
"help": "Maximum number of open TCPServer instances allowed. Each requires 72 bytes of pre-allocated RAM",
26+
"value": 4
27+
},
28+
"tcp-socket-max": {
29+
"help": "Maximum number of open TCPSocket instances allowed. Each requires 196 bytes of pre-allocated RAM",
30+
"value": 4
31+
},
32+
"udp-socket-max": {
33+
"help": "Maximum number of open UDPSocket instances allowed, including one used internally for DNS. Each requires 84 bytes of pre-allocated RAM",
34+
"value": 4
1935
}
2036
}
2137
}

0 commit comments

Comments
 (0)