Skip to content

Commit ff55aa3

Browse files
committed
Merge pull request #32 from adamgreen/netPerfRobustness
Updates to network code to improve performance/robustness
2 parents 370b270 + 657e6df commit ff55aa3

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

libraries/net/eth/lwip-eth/arch/lpc17_emac.c

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,38 @@ static struct pbuf *lpc_low_level_input(struct netif *netif)
428428
p = lpc_enetif->rxb[idx];
429429
p->len = (u16_t) length;
430430

431-
/* Free pbuf from desriptor */
431+
/* Free pbuf from descriptor */
432432
lpc_enetif->rxb[idx] = NULL;
433433
lpc_enetif->rx_free_descs++;
434434

435+
/* Attempt to queue new buffer(s) */
436+
if (lpc_rx_queue(lpc_enetif->netif) == 0) {
437+
/* Drop the frame due to OOM. */
438+
LINK_STATS_INC(link.drop);
439+
440+
/* Re-queue the pbuf for receive */
441+
lpc_rxqueue_pbuf(lpc_enetif, p);
442+
443+
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
444+
("lpc_low_level_input: Packet index %d dropped for OOM\n",
445+
idx));
446+
447+
#ifdef LOCK_RX_THREAD
448+
#if NO_SYS == 0
449+
sys_mutex_unlock(&lpc_enetif->TXLockMutex);
450+
#endif
451+
#endif
452+
453+
return NULL;
454+
}
455+
435456
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
436457
("lpc_low_level_input: Packet received: %p, size %d (index=%d)\n",
437458
p, length, idx));
438459

439460
/* Save size */
440461
p->tot_len = (u16_t) length;
441462
LINK_STATS_INC(link.recv);
442-
443-
/* Queue new buffer(s) */
444-
lpc_rx_queue(lpc_enetif->netif);
445463
}
446464
}
447465

libraries/net/lwip/lwip-sys/arch/sys_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ typedef struct {
5151
osMessageQId id;
5252
osMessageQDef_t def;
5353
#ifdef CMSIS_OS_RTX
54-
uint32_t queue[MB_SIZE];
54+
uint32_t queue[4+MB_SIZE]; /* The +4 is required for RTX OS_MCB overhead. */
5555
#endif
5656
} sys_mbox_t;
5757

libraries/net/lwip/lwip/lwipopts.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929

3030
#define LWIP_RAW 0
3131

32-
#define TCPIP_MBOX_SIZE 6
33-
#define DEFAULT_TCP_RECVMBOX_SIZE 6
34-
#define DEFAULT_UDP_RECVMBOX_SIZE 6
35-
#define DEFAULT_RAW_RECVMBOX_SIZE 6
36-
#define DEFAULT_ACCEPTMBOX_SIZE 6
32+
#define TCPIP_MBOX_SIZE 8
33+
#define DEFAULT_TCP_RECVMBOX_SIZE 8
34+
#define DEFAULT_UDP_RECVMBOX_SIZE 8
35+
#define DEFAULT_RAW_RECVMBOX_SIZE 8
36+
#define DEFAULT_ACCEPTMBOX_SIZE 8
3737

3838
#define TCPIP_THREAD_STACKSIZE 1024
39-
#define TCPIP_THREAD_PRIO 1
39+
#define TCPIP_THREAD_PRIO (osPriorityNormal)
4040

4141
#define DEFAULT_THREAD_STACKSIZE 512
4242

0 commit comments

Comments
 (0)