BadVPN – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | typedef struct my_custom_pbuf |
2 | { |
||
3 | struct pbuf_custom p; |
||
4 | void* dma_descriptor; |
||
5 | } my_custom_pbuf_t; |
||
6 | |||
7 | LWIP_MEMPOOL_DECLARE(RX_POOL, 10, sizeof(my_custom_pbuf_t), "Zero-copy RX PBUF pool"); |
||
8 | |||
9 | void my_pbuf_free_custom(void* p) |
||
10 | { |
||
11 | my_custom_pbuf_t* my_puf = (my_custom_pbuf_t*)p; |
||
12 | |||
13 | LOCK_INTERRUPTS(); |
||
14 | free_rx_dma_descriptor(my_pbuf->dma_descriptor); |
||
15 | LWIP_MEMPOOL_FREE(RX_POOL, my_pbuf); |
||
16 | UNLOCK_INTERRUPTS(); |
||
17 | } |
||
18 | |||
19 | void eth_rx_irq() |
||
20 | { |
||
21 | dma_descriptor* dma_desc = get_RX_DMA_descriptor_from_ethernet(); |
||
22 | my_custom_pbuf_t* my_pbuf = (my_custom_pbuf_t*)LWIP_MEMPOOL_ALLOC(RX_POOL); |
||
23 | |||
24 | my_pbuf->p.custom_free_function = my_pbuf_free_custom; |
||
25 | my_pbuf->dma_descriptor = dma_desc; |
||
26 | |||
27 | invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length); |
||
28 | |||
29 | struct pbuf* p = pbuf_alloced_custom(PBUF_RAW, |
||
30 | dma_desc->rx_length, |
||
31 | PBUF_REF, |
||
32 | &my_pbuf->p, |
||
33 | dma_desc->rx_data, |
||
34 | dma_desc->max_buffer_size); |
||
35 | |||
36 | if(netif->input(p, netif) != ERR_OK) { |
||
37 | pbuf_free(p); |
||
38 | } |
||
39 | } |