BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers memp_std.h Source File

memp_std.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * lwIP internal memory pools (do not use in application code)
00004  * This file is deliberately included multiple times: once with empty
00005  * definition of LWIP_MEMPOOL() to handle all includes and multiple times
00006  * to build up various lists of mem pools.
00007  */
00008 
00009 /*
00010  * SETUP: Make sure we define everything we will need.
00011  *
00012  * We have create three types of pools:
00013  *   1) MEMPOOL - standard pools
00014  *   2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
00015  *   3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
00016  *
00017  * If the include'r doesn't require any special treatment of each of the types
00018  * above, then will declare #2 & #3 to be just standard mempools.
00019  */
00020 #ifndef LWIP_MALLOC_MEMPOOL
00021 /* This treats "malloc pools" just like any other pool.
00022    The pools are a little bigger to provide 'size' as the amount of user data. */
00023 #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper))), "MALLOC_"#size)
00024 #define LWIP_MALLOC_MEMPOOL_START
00025 #define LWIP_MALLOC_MEMPOOL_END
00026 #endif /* LWIP_MALLOC_MEMPOOL */
00027 
00028 #ifndef LWIP_PBUF_MEMPOOL
00029 /* This treats "pbuf pools" just like any other pool.
00030  * Allocates buffers for a pbuf struct AND a payload size */
00031 #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
00032 #endif /* LWIP_PBUF_MEMPOOL */
00033 
00034 
00035 /*
00036  * A list of internal pools used by LWIP.
00037  *
00038  * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
00039  *     creates a pool name MEMP_pool_name. description is used in stats.c
00040  */
00041 #if LWIP_RAW
00042 LWIP_MEMPOOL(RAW_PCB,        MEMP_NUM_RAW_PCB,         sizeof(struct raw_pcb),        "RAW_PCB")
00043 #endif /* LWIP_RAW */
00044 
00045 #if LWIP_UDP
00046 LWIP_MEMPOOL(UDP_PCB,        MEMP_NUM_UDP_PCB,         sizeof(struct udp_pcb),        "UDP_PCB")
00047 #endif /* LWIP_UDP */
00048 
00049 #if LWIP_TCP
00050 LWIP_MEMPOOL(TCP_PCB,        MEMP_NUM_TCP_PCB,         sizeof(struct tcp_pcb),        "TCP_PCB")
00051 LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN,  sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
00052 LWIP_MEMPOOL(TCP_SEG,        MEMP_NUM_TCP_SEG,         sizeof(struct tcp_seg),        "TCP_SEG")
00053 #endif /* LWIP_TCP */
00054 
00055 #if LWIP_IPV4 && IP_REASSEMBLY
00056 LWIP_MEMPOOL(REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip_reassdata),   "REASSDATA")
00057 #endif /* LWIP_IPV4 && IP_REASSEMBLY */
00058 #if (IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)
00059 LWIP_MEMPOOL(FRAG_PBUF,      MEMP_NUM_FRAG_PBUF,       sizeof(struct pbuf_custom_ref),"FRAG_PBUF")
00060 #endif /* IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF || (LWIP_IPV6 && LWIP_IPV6_FRAG) */
00061 
00062 #if LWIP_NETCONN || LWIP_SOCKET
00063 LWIP_MEMPOOL(NETBUF,         MEMP_NUM_NETBUF,          sizeof(struct netbuf),         "NETBUF")
00064 LWIP_MEMPOOL(NETCONN,        MEMP_NUM_NETCONN,         sizeof(struct netconn),        "NETCONN")
00065 #endif /* LWIP_NETCONN || LWIP_SOCKET */
00066 
00067 #if NO_SYS==0
00068 LWIP_MEMPOOL(TCPIP_MSG_API,  MEMP_NUM_TCPIP_MSG_API,   sizeof(struct tcpip_msg),      "TCPIP_MSG_API")
00069 #if LWIP_MPU_COMPATIBLE
00070 LWIP_MEMPOOL(API_MSG,        MEMP_NUM_API_MSG,         sizeof(struct api_msg),        "API_MSG")
00071 #if LWIP_DNS
00072 LWIP_MEMPOOL(DNS_API_MSG,    MEMP_NUM_DNS_API_MSG,     sizeof(struct dns_api_msg),    "DNS_API_MSG")
00073 #endif
00074 #if LWIP_SOCKET && !LWIP_TCPIP_CORE_LOCKING
00075 LWIP_MEMPOOL(SOCKET_SETGETSOCKOPT_DATA, MEMP_NUM_SOCKET_SETGETSOCKOPT_DATA, sizeof(struct lwip_setgetsockopt_data), "SOCKET_SETGETSOCKOPT_DATA")
00076 #endif
00077 #if LWIP_NETIF_API
00078 LWIP_MEMPOOL(NETIFAPI_MSG,   MEMP_NUM_NETIFAPI_MSG,    sizeof(struct netifapi_msg),   "NETIFAPI_MSG")
00079 #endif
00080 #endif /* LWIP_MPU_COMPATIBLE */
00081 #if !LWIP_TCPIP_CORE_LOCKING_INPUT
00082 LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg),      "TCPIP_MSG_INPKT")
00083 #endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
00084 #endif /* NO_SYS==0 */
00085 
00086 #if LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING
00087 LWIP_MEMPOOL(ARP_QUEUE,      MEMP_NUM_ARP_QUEUE,       sizeof(struct etharp_q_entry), "ARP_QUEUE")
00088 #endif /* LWIP_IPV4 && LWIP_ARP && ARP_QUEUEING */
00089 
00090 #if LWIP_IGMP
00091 LWIP_MEMPOOL(IGMP_GROUP,     MEMP_NUM_IGMP_GROUP,      sizeof(struct igmp_group),     "IGMP_GROUP")
00092 #endif /* LWIP_IGMP */
00093 
00094 #if LWIP_TIMERS && !LWIP_TIMERS_CUSTOM
00095 LWIP_MEMPOOL(SYS_TIMEOUT,    MEMP_NUM_SYS_TIMEOUT,     sizeof(struct sys_timeo),      "SYS_TIMEOUT")
00096 #endif /* LWIP_TIMERS && !LWIP_TIMERS_CUSTOM */
00097 
00098 #if LWIP_DNS && LWIP_SOCKET
00099 LWIP_MEMPOOL(NETDB,          MEMP_NUM_NETDB,           NETDB_ELEM_SIZE,               "NETDB")
00100 #endif /* LWIP_DNS && LWIP_SOCKET */
00101 #if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
00102 LWIP_MEMPOOL(LOCALHOSTLIST,  MEMP_NUM_LOCALHOSTLIST,   LOCALHOSTLIST_ELEM_SIZE,       "LOCALHOSTLIST")
00103 #endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
00104 
00105 #if LWIP_IPV6 && LWIP_ND6_QUEUEING
00106 LWIP_MEMPOOL(ND6_QUEUE,      MEMP_NUM_ND6_QUEUE,       sizeof(struct nd6_q_entry), "ND6_QUEUE")
00107 #endif /* LWIP_IPV6 && LWIP_ND6_QUEUEING */
00108 
00109 #if LWIP_IPV6 && LWIP_IPV6_REASS
00110 LWIP_MEMPOOL(IP6_REASSDATA,      MEMP_NUM_REASSDATA,       sizeof(struct ip6_reassdata),   "IP6_REASSDATA")
00111 #endif /* LWIP_IPV6 && LWIP_IPV6_REASS */
00112 
00113 #if LWIP_IPV6 && LWIP_IPV6_MLD
00114 LWIP_MEMPOOL(MLD6_GROUP,     MEMP_NUM_MLD6_GROUP,      sizeof(struct mld_group),     "MLD6_GROUP")
00115 #endif /* LWIP_IPV6 && LWIP_IPV6_MLD */
00116 
00117 
00118 /*
00119  * A list of pools of pbuf's used by LWIP.
00120  *
00121  * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
00122  *     creates a pool name MEMP_pool_name. description is used in stats.c
00123  *     This allocates enough space for the pbuf struct and a payload.
00124  *     (Example: pbuf_payload_size=0 allocates only size for the struct)
00125  */
00126 LWIP_PBUF_MEMPOOL(PBUF,      MEMP_NUM_PBUF,            0,                             "PBUF_REF/ROM")
00127 LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE,           PBUF_POOL_BUFSIZE,             "PBUF_POOL")
00128 
00129 
00130 /*
00131  * Allow for user-defined pools; this must be explicitly set in lwipopts.h
00132  * since the default is to NOT look for lwippools.h
00133  */
00134 #if MEMP_USE_CUSTOM_POOLS
00135 #include "lwippools.h"
00136 #endif /* MEMP_USE_CUSTOM_POOLS */
00137 
00138 /*
00139  * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
00140  * (#undef is ignored for something that is not defined)
00141  */
00142 #undef LWIP_MEMPOOL
00143 #undef LWIP_MALLOC_MEMPOOL
00144 #undef LWIP_MALLOC_MEMPOOL_START
00145 #undef LWIP_MALLOC_MEMPOOL_END
00146 #undef LWIP_PBUF_MEMPOOL