ReactOS 0.4.16-dev-927-g467dec4
ZeroCopyRx.c
Go to the documentation of this file.
1typedef struct my_custom_pbuf
2{
3 struct pbuf_custom p;
6
7LWIP_MEMPOOL_DECLARE(RX_POOL, 10, sizeof(my_custom_pbuf_t), "Zero-copy RX PBUF pool");
8
10{
11 SYS_ARCH_DECL_PROTECT(old_level);
12
14
15 // invalidate data cache here - lwIP and/or application may have written into buffer!
16 // (invalidate is faster than flushing, and no one needs the correct data in the buffer)
17 invalidate_cpu_cache(p->payload, p->tot_len);
18
19 SYS_ARCH_PROTECT(old_level);
20 free_rx_dma_descriptor(my_pbuf->dma_descriptor);
21 LWIP_MEMPOOL_FREE(RX_POOL, my_pbuf);
22 SYS_ARCH_UNPROTECT(old_level);
23}
24
26{
27 dma_descriptor* dma_desc = get_RX_DMA_descriptor_from_ethernet();
29
30 my_pbuf->p.custom_free_function = my_pbuf_free_custom;
31 my_pbuf->dma_descriptor = dma_desc;
32
33 invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length);
34
35 struct pbuf* p = pbuf_alloced_custom(PBUF_RAW,
36 dma_desc->rx_length,
38 &my_pbuf->p,
39 dma_desc->rx_data,
40 dma_desc->max_buffer_size);
41
42 if(netif->input(p, netif) != ERR_OK) {
43 pbuf_free(p);
44 }
45}
struct my_custom_pbuf my_custom_pbuf_t
void my_pbuf_free_custom(void *p)
Definition: ZeroCopyRx.c:9
void eth_rx_irq()
Definition: ZeroCopyRx.c:25
#define SYS_ARCH_UNPROTECT(lev)
Definition: cc.h:39
#define SYS_ARCH_PROTECT(lev)
Definition: cc.h:38
#define SYS_ARCH_DECL_PROTECT(lev)
Definition: cc.h:37
GLfloat GLfloat p
Definition: glext.h:8902
@ ERR_OK
Definition: err.h:55
#define LWIP_MEMPOOL_DECLARE(name, num, size, desc)
Definition: memp.h:95
#define LWIP_MEMPOOL_ALLOC(name)
Definition: memp.h:122
#define LWIP_MEMPOOL_FREE(name, x)
Definition: memp.h:127
u8_t pbuf_free(struct pbuf *p)
Definition: pbuf.c:727
@ PBUF_REF
Definition: pbuf.h:160
@ PBUF_RAW
Definition: pbuf.h:111
struct pbuf_custom p
Definition: ZeroCopyRx.c:3
void * dma_descriptor
Definition: ZeroCopyRx.c:4
Definition: netif.h:269
netif_input_fn input
Definition: netif.h:297
Definition: pbuf.h:186