3 * lwIP internal memory pools (do not use in application code)
4 * This file is deliberately included multiple times: once with empty
5 * definition of LWIP_MEMPOOL() to handle all includes and multiple times
6 * to build up various lists of mem pools.
10 * SETUP: Make sure we define everything we will need.
12 * We have create three types of pools:
13 * 1) MEMPOOL - standard pools
14 * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
15 * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
17 * If the include'r doesn't require any special treatment of each of the types
18 * above, then will declare #2 & #3 to be just standard mempools.
20 #ifndef LWIP_MALLOC_MEMPOOL
21 /* This treats "malloc pools" just like any other pool.
22 The pools are a little bigger to provide 'size' as the amount of user data. */
23 #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size)
24 #define LWIP_MALLOC_MEMPOOL_START
25 #define LWIP_MALLOC_MEMPOOL_END
26 #endif /* LWIP_MALLOC_MEMPOOL */
28 #ifndef LWIP_PBUF_MEMPOOL
29 /* This treats "pbuf pools" just like any other pool.
30 * Allocates buffers for a pbuf struct AND a payload size */
31 #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
32 #endif /* LWIP_PBUF_MEMPOOL */
36 * A list of internal pools used by LWIP.
38 * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
39 * creates a pool name MEMP_pool_name. description is used in stats.c
42 LWIP_MEMPOOL(RAW_PCB
, MEMP_NUM_RAW_PCB
, sizeof(struct raw_pcb
), "RAW_PCB")
46 LWIP_MEMPOOL(UDP_PCB
, MEMP_NUM_UDP_PCB
, sizeof(struct udp_pcb
), "UDP_PCB")
50 LWIP_MEMPOOL(TCP_PCB
, MEMP_NUM_TCP_PCB
, sizeof(struct tcp_pcb
), "TCP_PCB")
51 LWIP_MEMPOOL(TCP_PCB_LISTEN
, MEMP_NUM_TCP_PCB_LISTEN
, sizeof(struct tcp_pcb_listen
), "TCP_PCB_LISTEN")
52 LWIP_MEMPOOL(TCP_SEG
, MEMP_NUM_TCP_SEG
, sizeof(struct tcp_seg
), "TCP_SEG")
55 #if LWIP_IPV4 && IP_REASSEMBLY
56 LWIP_MEMPOOL(REASSDATA
, MEMP_NUM_REASSDATA
, sizeof(struct ip_reassdata
), "REASSDATA")
57 #endif /* LWIP_IPV4 && IP_REASSEMBLY */
58 #if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)
59 LWIP_MEMPOOL(FRAG_PBUF
, MEMP_NUM_FRAG_PBUF
, sizeof(struct pbuf_custom_ref
),"FRAG_PBUF")
60 #endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */
62 #if LWIP_NETCONN || LWIP_SOCKET
63 LWIP_MEMPOOL(NETBUF
, MEMP_NUM_NETBUF
, sizeof(struct netbuf
), "NETBUF")
64 LWIP_MEMPOOL(NETCONN
, MEMP_NUM_NETCONN
, sizeof(struct netconn
), "NETCONN")
65 #endif /* LWIP_NETCONN || LWIP_SOCKET */
68 LWIP_MEMPOOL(TCPIP_MSG_API
, MEMP_NUM_TCPIP_MSG_API
, sizeof(struct tcpip_msg
), "TCPIP_MSG_API")
69 #if LWIP_MPU_COMPATIBLE
70 LWIP_MEMPOOL(API_MSG
, MEMP_NUM_API_MSG
, sizeof(struct api_msg
), "API_MSG")
72 LWIP_MEMPOOL(DNS_API_MSG
, MEMP_NUM_DNS_API_MSG
, sizeof(struct dns_api_msg
), "DNS_API_MSG")
74 #if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING
75 LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA
, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA
, sizeof(struct lwip_setgetsockopt_data
), "SOCKET_SETGETSOCKOPT_DATA")
78 LWIP_MEMPOOL(NETIFAPI_MSG
, MEMP_NUM_NETIFAPI_MSG
, sizeof(struct netifapi_msg
), "NETIFAPI_MSG")
80 #endif /* LWIP_MPU_COMPATIBLE */
81 #if !LWIP_TCPIP_CORE_LOCKING_INPUT
82 LWIP_MEMPOOL(TCPIP_MSG_INPKT
,MEMP_NUM_TCPIP_MSG_INPKT
, sizeof(struct tcpip_msg
), "TCPIP_MSG_INPKT")
83 #endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
84 #endif /* NO_SYS==0 */
86 #if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING
87 LWIP_MEMPOOL(ARP_QUEUE
, MEMP_NUM_ARP_QUEUE
, sizeof(struct etharp_q_entry
), "ARP_QUEUE")
88 #endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */
91 LWIP_MEMPOOL(IGMP_GROUP
, MEMP_NUM_IGMP_GROUP
, sizeof(struct igmp_group
), "IGMP_GROUP")
92 #endif /* LWIP_IGMP */
94 #if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM
95 LWIP_MEMPOOL(SYS_TIMEOUT
, MEMP_NUM_SYS_TIMEOUT
, sizeof(struct sys_timeo
), "SYS_TIMEOUT")
96 #endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
98 #if LWIP_DNS && LWIP_SOCKET
99 LWIP_MEMPOOL(NETDB
, MEMP_NUM_NETDB
, NETDB_ELEM_SIZE
, "NETDB")
100 #endif /* LWIP_DNS && LWIP_SOCKET */
101 #if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
102 LWIP_MEMPOOL(LOCALHOSTLIST
, MEMP_NUM_LOCALHOSTLIST
, LOCALHOSTLIST_ELEM_SIZE
, "LOCALHOSTLIST")
103 #endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
105 #if LWIP_IPV6 && LWIP_ND6_QUEUEING
106 LWIP_MEMPOOL(ND6_QUEUE
, MEMP_NUM_ND6_QUEUE
, sizeof(struct nd6_q_entry
), "ND6_QUEUE")
107 #endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */
109 #if LWIP_IPV6 && LWIP_IPV6_REASS
110 LWIP_MEMPOOL(IP6_REASSDATA
, MEMP_NUM_REASSDATA
, sizeof(struct ip6_reassdata
), "IP6_REASSDATA")
111 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
113 #if LWIP_IPV6 && LWIP_IPV6_MLD
114 LWIP_MEMPOOL(MLD6_GROUP
, MEMP_NUM_MLD6_GROUP
, sizeof(struct mld_group
), "MLD6_GROUP")
115 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
119 * A list of pools of pbuf's used by LWIP.
121 * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
122 * creates a pool name MEMP_pool_name. description is used in stats.c
123 * This allocates enough space for the pbuf struct and a payload.
124 * (Example: pbuf_payload_size=0 allocates only size for the struct)
126 LWIP_PBUF_MEMPOOL(PBUF
, MEMP_NUM_PBUF
, 0, "PBUF_REF/ROM")
127 LWIP_PBUF_MEMPOOL(PBUF_POOL
, PBUF_POOL_SIZE
, PBUF_POOL_BUFSIZE
, "PBUF_POOL")
131 * Allow for user-defined pools; this must be explicitly set in lwipopts.h
132 * since the default is to NOT look for lwippools.h
134 #if MEMP_USE_CUSTOM_POOLS
135 #include "lwippools.h"
136 #endif /* MEMP_USE_CUSTOM_POOLS */
139 * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
140 * (#undef is ignored for something that is not defined)
143 #undef LWIP_MALLOC_MEMPOOL
144 #undef LWIP_MALLOC_MEMPOOL_START
145 #undef LWIP_MALLOC_MEMPOOL_END
146 #undef LWIP_PBUF_MEMPOOL