|
24 | 24 | #endif
|
25 | 25 | #include "esp_log.h"
|
26 | 26 |
|
| 27 | +// use mempool and zero copy for Tx |
| 28 | +#include "mempool.h" |
| 29 | + |
27 | 30 | #if ESP_PKT_STATS
|
28 | 31 | struct pkt_stats_t pkt_stats;
|
29 | 32 | void *pkt_stats_thread = NULL;
|
@@ -52,6 +55,13 @@ static void * raw_tp_tx_task_id = 0;
|
52 | 55 | static uint64_t test_raw_tx_len = 0;
|
53 | 56 | static uint64_t test_raw_rx_len = 0;
|
54 | 57 |
|
| 58 | +static struct mempool * buf_mp_g = NULL; |
| 59 | + |
| 60 | +void stats_mempool_free(void* ptr) |
| 61 | +{ |
| 62 | + mempool_free(buf_mp_g, ptr); |
| 63 | +} |
| 64 | + |
55 | 65 | void test_raw_tp_cleanup(void)
|
56 | 66 | {
|
57 | 67 | int ret = 0;
|
@@ -102,25 +112,30 @@ static void raw_tp_tx_task(void const* pvParameters)
|
102 | 112 | uint32_t i = 0;
|
103 | 113 | g_h.funcs->_h_sleep(5);
|
104 | 114 |
|
| 115 | + buf_mp_g = mempool_create(MAX_TRANSPORT_BUFFER_SIZE); |
| 116 | +#ifdef CONFIG_ESP_CACHE_MALLOC |
| 117 | + assert(channel->memp); |
| 118 | +#endif |
| 119 | + |
105 | 120 | while (1) {
|
106 | 121 |
|
107 | 122 | #if CONFIG_H_LOWER_MEMCOPY
|
108 | 123 | raw_tp_tx_buf = (uint8_t*)g_h.funcs->_h_calloc(1, MAX_TRANSPORT_BUFFER_SIZE);
|
109 | 124 |
|
110 | 125 | ptr = (uint32_t*) raw_tp_tx_buf;
|
111 | 126 | for (i=0; i<(TEST_RAW_TP__BUF_SIZE/4-1); i++, ptr++)
|
112 |
| - *ptr = 0xBAADF00D; |
| 127 | + *ptr = 0xBAADF00D; |
113 | 128 |
|
114 | 129 | ret = esp_hosted_tx(ESP_TEST_IF, 0, raw_tp_tx_buf, TEST_RAW_TP__BUF_SIZE, H_BUFF_ZEROCOPY, H_DEFLT_FREE_FUNC);
|
115 | 130 |
|
116 | 131 | #else
|
117 |
| - raw_tp_tx_buf = (uint8_t*)g_h.funcs->_h_calloc(1, TEST_RAW_TP__BUF_SIZE); |
| 132 | + raw_tp_tx_buf = mempool_alloc(buf_mp_g, MAX_TRANSPORT_BUFFER_SIZE, true); |
118 | 133 |
|
119 |
| - ptr = (uint32_t*) raw_tp_tx_buf; |
| 134 | + ptr = (uint32_t*) (raw_tp_tx_buf + H_ESP_PAYLOAD_HEADER_OFFSET); |
120 | 135 | for (i=0; i<(TEST_RAW_TP__BUF_SIZE/4-1); i++, ptr++)
|
121 |
| - *ptr = 0xBAADF00D; |
| 136 | + *ptr = 0xBAADF00D; |
122 | 137 |
|
123 |
| - ret = esp_hosted_tx(ESP_TEST_IF, 0, raw_tp_tx_buf, TEST_RAW_TP__BUF_SIZE, H_BUFF_NO_ZEROCOPY, H_DEFLT_FREE_FUNC); |
| 138 | + ret = esp_hosted_tx(ESP_TEST_IF, 0, raw_tp_tx_buf, TEST_RAW_TP__BUF_SIZE, H_BUFF_ZEROCOPY, stats_mempool_free); |
124 | 139 | #endif
|
125 | 140 | if (ret != STM_OK) {
|
126 | 141 | ESP_LOGE(TAG, "Failed to send to queue\n");
|
|
0 commit comments