Skip to content

Commit

Permalink
Switched to tcpip_input, mbuf allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
neimanra committed Jul 21, 2015
1 parent b762926 commit 4094c86
Show file tree
Hide file tree
Showing 7 changed files with 238 additions and 92 deletions.
13 changes: 9 additions & 4 deletions lwip/src/core/pbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
switch (type) {
case PBUF_POOL:
/* allocate head of pbuf chain into p */
p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL);
//p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); //TODO
p = sys_arch_allocate_pbuf();

LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p));
if (p == NULL) {
PBUF_POOL_IS_EMPTY();
Expand Down Expand Up @@ -305,7 +307,8 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
break;
case PBUF_RAM:
/* If pbuf is to be allocated in RAM, allocate memory for it. */
p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length));
//p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length));//TODO
p = sys_arch_allocate_pbuf();
if (p == NULL) {
return NULL;
}
Expand Down Expand Up @@ -668,13 +671,15 @@ pbuf_free(struct pbuf *p)
{
/* is this a pbuf from the pool? */
if (type == PBUF_POOL) {
memp_free(MEMP_PBUF_POOL, p);
//memp_free(MEMP_PBUF_POOL, p);//TODO
sys_arch_free_pbuf(p);
/* is this a ROM or RAM referencing pbuf? */
} else if (type == PBUF_ROM || type == PBUF_REF) {
memp_free(MEMP_PBUF, p);
/* type == PBUF_RAM */
} else {
mem_free(p);
// mem_free(p);
sys_arch_free_pbuf(p);//TODO
}
}
count++;
Expand Down
2 changes: 1 addition & 1 deletion lwip/src/include/lwip/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
*/
#define LWIP_DEBUGF(debug, message) do { \
if ( \
((debug) & LWIP_DBG_ON) && \
((debug) & LWIP_DBG_OFF) && \
((debug) & LWIP_DBG_TYPES_ON) && \
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
LWIP_PLATFORM_DIAG(message); \
Expand Down
6 changes: 4 additions & 2 deletions proj/include/arch/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* Include user defined options first. Anything not defined in these files
* will be set to standard values. Override anything you dont like!
*/
#include "lwipopts.h"
//#include "lwipopts.h"
#include "lwip/debug.h"

/*
Expand Down Expand Up @@ -88,6 +88,8 @@
---------- Internal Memory Pool Sizes ----------
------------------------------------------------
*/


/**
* MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF).
* If the application sends a lot of data out of ROM (or other static memory),
Expand Down Expand Up @@ -124,7 +126,7 @@
* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments.
* (requires the LWIP_TCP option)
*/
#define MEMP_NUM_TCP_SEG 16
#define MEMP_NUM_TCP_SEG 64//16

/**
* MEMP_NUM_REASSDATA: the number of simultaneously IP packets queued for
Expand Down
3 changes: 3 additions & 0 deletions proj/include/arch/sys_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ typedef struct sys_thread * sys_thread_t;
#define sys_mbox_valid(mbox) (((mbox) != NULL) && (*(mbox) != NULL))
#define sys_mbox_set_invalid(mbox) do { if((mbox) != NULL) { *(mbox) = NULL; }}while(0)

struct pbuf * sys_arch_allocate_pbuf();
void sys_arch_free_pbuf(struct pbuf * pbuf);

#endif /* __ARCH_SYS_ARCH_H__ */
2 changes: 1 addition & 1 deletion proj/src/app/unixlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ tcpip_init_done(void *arg)
IP4_ADDR(&netmask, 255,255,255,0);

netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gateway, NULL, dpdkif_init,
ethernet_input));
tcpip_input/*ethernet_input*/));

netif_set_up(&netif);
sys_sem_signal(sem);
Expand Down
Loading

0 comments on commit 4094c86

Please sign in to comment.