memp_std.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * SETUP: Make sure we define everything we will need.
  3. *
  4. * We have create three types of pools:
  5. * 1) MEMPOOL - standard pools
  6. * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
  7. * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
  8. *
  9. * If the include'r doesn't require any special treatment of each of the types
  10. * above, then will declare #2 & #3 to be just standard mempools.
  11. */
  12. #ifndef LWIP_MALLOC_MEMPOOL
  13. /* This treats "malloc pools" just like any other pool.
  14. The pools are a little bigger to provide 'size' as the amount of user data. */
  15. #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size, attr)
  16. #define LWIP_MALLOC_MEMPOOL_START
  17. #define LWIP_MALLOC_MEMPOOL_END
  18. #endif /* LWIP_MALLOC_MEMPOOL */
  19. #ifndef LWIP_PBUF_MEMPOOL
  20. /* This treats "pbuf pools" just like any other pool.
  21. * Allocates buffers for a pbuf struct AND a payload size */
  22. #define LWIP_PBUF_MEMPOOL(name, num, payload, desc, attr) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc, attr)
  23. #endif /* LWIP_PBUF_MEMPOOL */
  24. /*
  25. * A list of internal pools used by LWIP.
  26. *
  27. * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
  28. * creates a pool name MEMP_pool_name. description is used in stats.c
  29. */
  30. #if LWIP_RAW
  31. LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB", DMEM_ATTR)
  32. #endif /* LWIP_RAW */
  33. #if LWIP_UDP
  34. LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB", DMEM_ATTR)
  35. #endif /* LWIP_UDP */
  36. #if LWIP_TCP
  37. LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB", DMEM_ATTR)
  38. LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN", DMEM_ATTR)
  39. LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG", DMEM_ATTR)
  40. #endif /* LWIP_TCP */
  41. #if IP_REASSEMBLY
  42. LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA", DMEM_ATTR)
  43. #endif /* IP_REASSEMBLY */
  44. #if IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF
  45. LWIP_MEMPOOL(FRAG_PBUF, MEMP_NUM_FRAG_PBUF, sizeof(struct pbuf_custom_ref),"FRAG_PBUF", DMEM_ATTR)
  46. #endif /* IP_FRAG && !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */
  47. #if LWIP_NETCONN
  48. LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
  49. LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")
  50. #endif /* LWIP_NETCONN */
  51. #if NO_SYS==0
  52. LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API")
  53. #if !LWIP_TCPIP_CORE_LOCKING_INPUT
  54. LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT")
  55. #endif /* !LWIP_TCPIP_CORE_LOCKING_INPUT */
  56. #endif /* NO_SYS==0 */
  57. #if ARP_QUEUEING
  58. LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE", DMEM_ATTR)
  59. #endif /* ARP_QUEUEING */
  60. #if LWIP_IGMP
  61. LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP", DMEM_ATTR)
  62. #endif /* LWIP_IGMP */
  63. #if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */
  64. LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT", DMEM_ATTR)
  65. #endif /* LWIP_TIMERS */
  66. #if LWIP_SNMP
  67. LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE")
  68. LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE")
  69. LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND")
  70. LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE")
  71. #endif /* LWIP_SNMP */
  72. #if LWIP_DNS && LWIP_SOCKET
  73. LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
  74. #endif /* LWIP_DNS && LWIP_SOCKET */
  75. #if LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
  76. LWIP_MEMPOOL(LOCALHOSTLIST, MEMP_NUM_LOCALHOSTLIST, LOCALHOSTLIST_ELEM_SIZE, "LOCALHOSTLIST")
  77. #endif /* LWIP_DNS && DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
  78. #if PPP_SUPPORT && PPPOE_SUPPORT
  79. LWIP_MEMPOOL(PPPOE_IF, MEMP_NUM_PPPOE_INTERFACES, sizeof(struct pppoe_softc), "PPPOE_IF")
  80. #endif /* PPP_SUPPORT && PPPOE_SUPPORT */
  81. /*
  82. * A list of pools of pbuf's used by LWIP.
  83. *
  84. * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
  85. * creates a pool name MEMP_pool_name. description is used in stats.c
  86. * This allocates enough space for the pbuf struct and a payload.
  87. * (Example: pbuf_payload_size=0 allocates only size for the struct)
  88. */
  89. LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM", DMEM_ATTR)
  90. /* XXX: need to align to 4 byte as memp strcut is 4-byte long. otherwise will crash */
  91. #define LWIP_MEM_ALIGN4_SIZE(size) (((size) + 4 - 1) & ~(4-1))
  92. LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, LWIP_MEM_ALIGN4_SIZE(PBUF_POOL_BUFSIZE), "PBUF_POOL", DMEM_ATTR)
  93. /*
  94. * Allow for user-defined pools; this must be explicitly set in lwipopts.h
  95. * since the default is to NOT look for lwippools.h
  96. */
  97. #if MEMP_USE_CUSTOM_POOLS
  98. #include "lwippools.h"
  99. #endif /* MEMP_USE_CUSTOM_POOLS */
  100. /*
  101. * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
  102. * (#undef is ignored for something that is not defined)
  103. */
  104. #undef LWIP_MEMPOOL
  105. #undef LWIP_MALLOC_MEMPOOL
  106. #undef LWIP_MALLOC_MEMPOOL_START
  107. #undef LWIP_MALLOC_MEMPOOL_END
  108. #undef LWIP_PBUF_MEMPOOL