diff options
| author | Dirk Ziegelmeier <[email protected]> | 2017-04-27 12:40:16 +0200 |
|---|---|---|
| committer | Dirk Ziegelmeier <[email protected]> | 2017-04-27 12:41:08 +0200 |
| commit | a09a8e4a06d7b7d4bde06dcde38fc8233f584b47 (patch) | |
| tree | f38a037ea14f5fb550c9f96f2b4b6639f3993964 /doc | |
| parent | 6aac9377eed40a5bac68b8ddfbcce4596a26b398 (diff) | |
Some documentation updates and fixes
Dedicated Zero-copy RX page
Fix doxygen warnings
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/ZeroCopyRx.c | 39 | ||||
| -rw-r--r-- | doc/doxygen/main_page.h | 6 |
2 files changed, 45 insertions, 0 deletions
diff --git a/doc/ZeroCopyRx.c b/doc/ZeroCopyRx.c new file mode 100644 index 00000000..525b28ff --- /dev/null +++ b/doc/ZeroCopyRx.c @@ -0,0 +1,39 @@ +typedef struct my_custom_pbuf +{ + struct pbuf_custom p; + void* dma_descriptor; +} my_custom_pbuf_t; + +LWIP_MEMPOOL_DECLARE(RX_POOL, 10, sizeof(my_custom_pbuf_t), "Zero-copy RX PBUF pool"); + +void my_pbuf_free_custom(void* p) +{ + my_custom_pbuf_t* my_puf = (my_custom_pbuf_t*)p; + + LOCK_INTERRUPTS(); + free_rx_dma_descriptor(my_pbuf->dma_descriptor); + LWIP_MEMPOOL_FREE(RX_POOL, my_pbuf); + UNLOCK_INTERRUPTS(); +} + +void eth_rx_irq() +{ + dma_descriptor* dma_desc = get_RX_DMA_descriptor_from_ethernet(); + my_custom_pbuf_t* my_pbuf = (my_custom_pbuf_t*)LWIP_MEMPOOL_ALLOC(RX_POOL); + + my_pbuf->p.custom_free_function = my_pbuf_free_custom; + my_pbuf->dma_descriptor = dma_desc; + + invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length); + + struct pbuf* p = pbuf_alloced_custom(PBUF_RAW, + dma_desc->rx_length, + PBUF_REF, + &my_pbuf->p, + dma_desc->rx_data, + dma_desc->max_buffer_size); + + if(netif->input(p, netif) != ERR_OK) { + pbuf_free(p); + } +} diff --git a/doc/doxygen/main_page.h b/doc/doxygen/main_page.h index 0fc9bee0..efe11a64 100644 --- a/doc/doxygen/main_page.h +++ b/doc/doxygen/main_page.h @@ -101,6 +101,12 @@ */ /** + * @page zerocopyrx Zero-copy RX + * The following code is an example for zero-copy RX ethernet driver: + * @include ZeroCopyRx.c + */ + +/** * @defgroup lwip_nosys Mainloop mode ("NO_SYS") * @ingroup lwip * Use this mode if you do not run an OS on your system. \#define NO_SYS to 1. |
