mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-29 12:14:28 +00:00
(see task #6831): Included new option PBUF_POOL_USES_MEMP to use a memp pool for PBUF_POOL pbufs instead of the old pool implementation in pbuf.c to remove redundant code.
This commit is contained in:
parent
055e3d52b6
commit
a5e2e9ea03
@ -23,6 +23,11 @@ HISTORY
|
||||
|
||||
++ New features:
|
||||
|
||||
2007-05-10 Simon Goldschmidt
|
||||
* opt.h, memp.h, memp.c, pbuf.c (see task #6831): Included new option
|
||||
PBUF_POOL_USES_MEMP to use a memp pool for PBUF_POOL pbufs instead of the
|
||||
old pool implementation in pbuf.c to remove redundant code.
|
||||
|
||||
2007-05-11 Frédéric Bernon
|
||||
* sockets.c, api_lib.c, api_msg.h, api_msg.c, netifapi.h, netifapi.c, tcpip.c:
|
||||
Include a function pointer instead of a table index in the message to reduce
|
||||
|
@ -69,6 +69,9 @@ static const u16_t memp_sizes[MEMP_MAX] = {
|
||||
MEM_ALIGN_SIZE(sizeof(struct tcpip_msg)),
|
||||
#if ARP_QUEUEING
|
||||
MEM_ALIGN_SIZE(sizeof(struct etharp_q_entry)),
|
||||
#endif
|
||||
#if PBUF_POOL_USES_MEMP
|
||||
MEM_ALIGN_SIZE(sizeof(struct pbuf)) + MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE),
|
||||
#endif
|
||||
MEM_ALIGN_SIZE(sizeof(struct sys_timeo))
|
||||
};
|
||||
@ -85,6 +88,9 @@ static const u16_t memp_num[MEMP_MAX] = {
|
||||
MEMP_NUM_TCPIP_MSG,
|
||||
#if ARP_QUEUEING
|
||||
MEMP_NUM_ARP_QUEUE,
|
||||
#endif
|
||||
#if PBUF_POOL_USES_MEMP
|
||||
PBUF_POOL_SIZE,
|
||||
#endif
|
||||
MEMP_NUM_SYS_TIMEOUT
|
||||
};
|
||||
@ -104,6 +110,10 @@ static u8_t memp_memory[MEM_ALIGNMENT - 1 +
|
||||
MEMP_TYPE_SIZE(MEMP_NUM_TCPIP_MSG, struct tcpip_msg) +
|
||||
#if ARP_QUEUEING
|
||||
MEMP_TYPE_SIZE(MEMP_NUM_ARP_QUEUE, struct etharp_q_entry) +
|
||||
#endif
|
||||
#if PBUF_POOL_USES_MEMP
|
||||
MEMP_TYPE_SIZE(PBUF_POOL_SIZE, struct pbuf) +
|
||||
PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) +
|
||||
#endif
|
||||
MEMP_TYPE_SIZE(MEMP_NUM_SYS_TIMEOUT, struct sys_timeo)];
|
||||
|
||||
|
@ -74,12 +74,14 @@
|
||||
|
||||
#define SIZEOF_STRUCT_PBUF MEM_ALIGN_SIZE(sizeof(struct pbuf))
|
||||
|
||||
#if !PBUF_POOL_USES_MEMP
|
||||
static u8_t pbuf_pool_memory[MEM_ALIGNMENT - 1 + PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE) + SIZEOF_STRUCT_PBUF];
|
||||
|
||||
static struct pbuf *pbuf_pool = NULL;
|
||||
|
||||
/* Forward declaration */
|
||||
static void pbuf_pool_init(void);
|
||||
#endif /* PBUF_POOL_USES_MEMP */
|
||||
|
||||
/**
|
||||
* Initializes the pbuf module.
|
||||
@ -93,9 +95,12 @@ pbuf_init(void)
|
||||
LWIP_ASSERT("pbuf_init: PBUF_POOL_BUFSIZE not aligned",
|
||||
(PBUF_POOL_BUFSIZE % MEM_ALIGNMENT) == 0);
|
||||
|
||||
#if !PBUF_POOL_USES_MEMP
|
||||
pbuf_pool_init();
|
||||
#endif /* PBUF_POOL_USES_MEMP */
|
||||
}
|
||||
|
||||
#if !PBUF_POOL_USES_MEMP
|
||||
/**
|
||||
* Initializes the pbuf pool.
|
||||
*
|
||||
@ -192,6 +197,10 @@ pbuf_pool_free(struct pbuf *p)
|
||||
#endif
|
||||
SYS_ARCH_UNPROTECT(old_level);
|
||||
}
|
||||
#else /* PBUF_POOL_USES_MEMP */
|
||||
#define pbuf_pool_alloc() memp_malloc(MEMP_PBUF_POOL)
|
||||
#define pbuf_pool_free(p) memp_free(MEMP_PBUF_POOL, p)
|
||||
#endif /* PBUF_POOL_USES_MEMP */
|
||||
|
||||
/**
|
||||
* Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type).
|
||||
@ -260,6 +269,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
||||
if (p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
p->flags = PBUF_FLAG_POOL;
|
||||
p->next = NULL;
|
||||
|
||||
/* make the payload pointer point 'offset' bytes into pbuf data memory */
|
||||
@ -288,6 +298,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
|
||||
/* bail out unsuccesfully */
|
||||
return NULL;
|
||||
}
|
||||
q->flags = PBUF_FLAG_POOL;
|
||||
q->next = NULL;
|
||||
/* make previous pbuf point to this pbuf */
|
||||
r->next = q;
|
||||
|
@ -53,6 +53,9 @@ typedef enum {
|
||||
MEMP_TCPIP_MSG,
|
||||
#if ARP_QUEUEING
|
||||
MEMP_ARP_QUEUE,
|
||||
#endif
|
||||
#if PBUF_POOL_USES_MEMP
|
||||
MEMP_PBUF_POOL,
|
||||
#endif
|
||||
MEMP_SYS_TIMEOUT,
|
||||
|
||||
|
@ -377,21 +377,25 @@ a lot of data that needs to be copied, this should be set high. */
|
||||
|
||||
|
||||
/* ---------- Pbuf options ---------- */
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
/* PBUF_POOL_USES_MEMP: if set to 1, PBUF_POOL pbufs are allocated using an
|
||||
additional memp type, which saves some code since a dedicated pbuf pool
|
||||
is not used any more */
|
||||
#ifndef PBUF_POOL_USES_MEMP
|
||||
#define PBUF_POOL_USES_MEMP 0
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
|
||||
#ifndef PBUF_POOL_SIZE
|
||||
#define PBUF_POOL_SIZE 16
|
||||
#endif
|
||||
|
||||
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
|
||||
link level header. Defaults to 14 for Ethernet. */
|
||||
|
||||
#ifndef PBUF_LINK_HLEN
|
||||
#define PBUF_LINK_HLEN 14
|
||||
#endif
|
||||
|
||||
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
|
||||
|
||||
#ifndef PBUF_POOL_BUFSIZE
|
||||
/* Default designed to accomodate single full size TCP frame in one PBUF */
|
||||
/* TCP_MSS + 40 for IP and TCP headers + physical layer headers */
|
||||
|
Loading…
Reference in New Issue
Block a user