(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:
goldsimon
2007-05-13 16:16:03 +00:00
parent 055e3d52b6
commit a5e2e9ea03
5 changed files with 37 additions and 4 deletions

View File

@@ -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)];

View File

@@ -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;