mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-04 13:34:38 +08:00
PPP, reduced by one buffer PPPoS RX requirements in multithreaded context
Removed one unecessary allocated PBUF per PPPoS RX packet if PPP_INPROC_MULTITHREADED is set by adding the necessary data for pppos_input_callback() in front of the first pbuf instead of allocating a new buffer.
This commit is contained in:
parent
cf3162cff1
commit
2ceae6014e
@ -1522,12 +1522,6 @@ ppp_drop(ppp_pcb_rx *pcrx)
|
|||||||
snmp_inc_ifindiscards(&pcb->netif);
|
snmp_inc_ifindiscards(&pcb->netif);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PPP_INPROC_MULTITHREADED
|
|
||||||
struct ppp_tcpip_callback_header {
|
|
||||||
ppp_pcb *pcb;
|
|
||||||
};
|
|
||||||
#endif /* PPP_INPROC_MULTITHREADED */
|
|
||||||
|
|
||||||
/** Pass received raw characters to PPPoS to be decoded. This function is
|
/** Pass received raw characters to PPPoS to be decoded. This function is
|
||||||
* thread-safe and can be called from a dedicated RX-thread or from a main-loop.
|
* thread-safe and can be called from a dedicated RX-thread or from a main-loop.
|
||||||
*
|
*
|
||||||
@ -1583,10 +1577,6 @@ pppos_input(ppp_pcb *pcb, u_char *s, int l)
|
|||||||
/* Otherwise it's a good packet so pass it on. */
|
/* Otherwise it's a good packet so pass it on. */
|
||||||
} else {
|
} else {
|
||||||
struct pbuf *inp;
|
struct pbuf *inp;
|
||||||
#if PPP_INPROC_MULTITHREADED
|
|
||||||
struct pbuf *head;
|
|
||||||
struct ppp_tcpip_callback_header *cbhead;
|
|
||||||
#endif /* PPP_INPROC_MULTITHREADED */
|
|
||||||
/* Trim off the checksum. */
|
/* Trim off the checksum. */
|
||||||
if(pcrx->in_tail->len > 2) {
|
if(pcrx->in_tail->len > 2) {
|
||||||
pcrx->in_tail->len -= 2;
|
pcrx->in_tail->len -= 2;
|
||||||
@ -1610,21 +1600,14 @@ pppos_input(ppp_pcb *pcb, u_char *s, int l)
|
|||||||
pcrx->in_head = NULL;
|
pcrx->in_head = NULL;
|
||||||
pcrx->in_tail = NULL;
|
pcrx->in_tail = NULL;
|
||||||
#if PPP_INPROC_MULTITHREADED
|
#if PPP_INPROC_MULTITHREADED
|
||||||
head = pbuf_alloc(PBUF_RAW, sizeof(struct ppp_tcpip_callback_header), PBUF_POOL);
|
if(tcpip_callback_with_block(pppos_input_callback, inp, 0) != ERR_OK) {
|
||||||
if(NULL != head) {
|
PPPDEBUG(LOG_ERR, ("pppos_input[%d]: tcpip_callback() failed, dropping packet\n", pcb->num));
|
||||||
cbhead = (struct ppp_tcpip_callback_header*)head->payload;
|
pbuf_free(inp);
|
||||||
cbhead->pcb = pcb;
|
LINK_STATS_INC(link.drop);
|
||||||
pbuf_chain(head, inp);
|
snmp_inc_ifindiscards(&pcb->netif);
|
||||||
if(tcpip_callback_with_block(pppos_input_callback, head, 0) != ERR_OK) {
|
|
||||||
PPPDEBUG(LOG_ERR, ("pppos_input[%d]: tcpip_callback() failed, dropping packet\n", pcb->num));
|
|
||||||
pbuf_free(head);
|
|
||||||
pbuf_free(inp);
|
|
||||||
LINK_STATS_INC(link.drop);
|
|
||||||
snmp_inc_ifindiscards(&pcb->netif);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#else /* PPP_INPROC_MULTITHREADED */
|
#else /* PPP_INPROC_MULTITHREADED */
|
||||||
ppp_input(pcrx->pcb, inp);
|
ppp_input(pcb, inp);
|
||||||
#endif /* PPP_INPROC_MULTITHREADED */
|
#endif /* PPP_INPROC_MULTITHREADED */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1726,10 +1709,15 @@ pppos_input(ppp_pcb *pcb, u_char *s, int l)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pcrx->in_head == NULL) {
|
if (pcrx->in_head == NULL) {
|
||||||
((u8_t*)next_pbuf->payload)[0] = pcrx->in_protocol >> 8;
|
u8_t *payload = next_pbuf->payload;
|
||||||
((u8_t*)next_pbuf->payload)[1] = pcrx->in_protocol & 0xFF;
|
#if PPP_INPROC_MULTITHREADED
|
||||||
|
*((ppp_pcb**)payload) = pcb;
|
||||||
|
payload += sizeof(ppp_pcb*);
|
||||||
|
next_pbuf->len += sizeof(ppp_pcb*);
|
||||||
|
#endif /* PPP_INPROC_MULTITHREADED */
|
||||||
|
*(payload++) = pcrx->in_protocol >> 8;
|
||||||
|
*(payload) = pcrx->in_protocol & 0xFF;
|
||||||
next_pbuf->len += sizeof(pcrx->in_protocol);
|
next_pbuf->len += sizeof(pcrx->in_protocol);
|
||||||
|
|
||||||
pcrx->in_head = next_pbuf;
|
pcrx->in_head = next_pbuf;
|
||||||
}
|
}
|
||||||
pcrx->in_tail = next_pbuf;
|
pcrx->in_tail = next_pbuf;
|
||||||
@ -1749,33 +1737,25 @@ pppos_input(ppp_pcb *pcb, u_char *s, int l)
|
|||||||
|
|
||||||
#if PPP_INPROC_MULTITHREADED
|
#if PPP_INPROC_MULTITHREADED
|
||||||
/* PPPoS input callback using one input pointer
|
/* PPPoS input callback using one input pointer
|
||||||
* *arg is a pbuf chain of two chained pbuf, the first contains
|
|
||||||
* a pointer to the PPP PCB structure, the second contains the
|
|
||||||
* PPP payload
|
|
||||||
*/
|
*/
|
||||||
static void pppos_input_callback(void *arg) {
|
static void pppos_input_callback(void *arg) {
|
||||||
struct pbuf *hd, *pl;
|
struct pbuf *pb = (struct pbuf*)arg;
|
||||||
struct ppp_tcpip_callback_header *cbhead;
|
|
||||||
ppp_pcb *pcb;
|
ppp_pcb *pcb;
|
||||||
|
|
||||||
hd = (struct pbuf *)arg;
|
pcb = *((ppp_pcb**)pb->payload);
|
||||||
cbhead = (struct ppp_tcpip_callback_header *)hd->payload;
|
if(pbuf_header(pb, -(s16_t)sizeof(ppp_pcb*))) {
|
||||||
pcb = cbhead->pcb;
|
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||||
|
|
||||||
pl = hd->next;
|
|
||||||
pbuf_free(hd);
|
|
||||||
if(NULL == pl)
|
|
||||||
goto drop;
|
goto drop;
|
||||||
|
}
|
||||||
|
|
||||||
/* Dispatch the packet thereby consuming it. */
|
/* Dispatch the packet thereby consuming it. */
|
||||||
ppp_input(pcb, pl);
|
ppp_input(pcb, pb);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
drop:
|
drop:
|
||||||
LINK_STATS_INC(link.drop);
|
LINK_STATS_INC(link.drop);
|
||||||
snmp_inc_ifindiscards(&pcb->netif);
|
snmp_inc_ifindiscards(&pcb->netif);
|
||||||
pbuf_free(pl);
|
pbuf_free(pb);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
#endif /* PPP_INPROC_MULTITHREADED */
|
#endif /* PPP_INPROC_MULTITHREADED */
|
||||||
#endif /* PPPOS_SUPPORT */
|
#endif /* PPPOS_SUPPORT */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user