while (emac_config.cnt_rx < DMA_RX_BUF_NUM) {
+ emac_config.cnt_rx++;
+
//copy data to lwip
emac_config.emac_tcpip_input((void *)(emac_config.dma_erx[emac_config.dirty_rx].basic.desc2),
(((emac_config.dma_erx[emac_config.dirty_rx].basic.desc0) >> EMAC_DESC_FRAME_LENGTH_S) & EMAC_DESC_FRAME_LENGTH) , NULL);
- emac_config.cnt_rx++;
+
if (emac_config.cnt_rx > DMA_RX_BUF_NUM) {
ESP_LOGE(TAG, "emac rx unavail buf err !!\n");
}
if (((uint32_t) & (emac_config.dma_erx[emac_config.dirty_rx].basic.desc0) != cur_rx_desc)) {
while (((uint32_t) & (emac_config.dma_erx[emac_config.dirty_rx].basic.desc0) != cur_rx_desc) && emac_config.cnt_rx < DMA_RX_BUF_NUM ) {
+ emac_config.cnt_rx++;
+
//copy data to lwip
emac_config.emac_tcpip_input((void *)(emac_config.dma_erx[emac_config.dirty_rx].basic.desc2),
(((emac_config.dma_erx[emac_config.dirty_rx].basic.desc0) >> EMAC_DESC_FRAME_LENGTH_S) & EMAC_DESC_FRAME_LENGTH) , NULL);
- emac_config.cnt_rx++;
-
if (emac_config.cnt_rx > DMA_RX_BUF_NUM ) {
ESP_LOGE(TAG, "emac rx buf err!!\n");
}
if ((emac_config.dma_erx[emac_config.dirty_rx].basic.desc0 & EMAC_DESC_RX_OWN) == 0) {
while (emac_config.cnt_rx < DMA_RX_BUF_NUM) {
+ emac_config.cnt_rx++;
//copy data to lwip
emac_config.emac_tcpip_input((void *)(emac_config.dma_erx[emac_config.dirty_rx].basic.desc2),
(((emac_config.dma_erx[emac_config.dirty_rx].basic.desc0) >> EMAC_DESC_FRAME_LENGTH_S) & EMAC_DESC_FRAME_LENGTH) , NULL);
- emac_config.cnt_rx++;
+
if (emac_config.cnt_rx > DMA_RX_BUF_NUM) {
ESP_LOGE(TAG, "emac rx buf err!!!\n");
}
* the appropriate input function is called.
*
* @param netif the lwip network interface structure for this ethernetif
+ * @param buffer the ethernet buffer
+ * @param len the len of buffer
+ *
+ * @note When CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE is enabled, a copy of buffer
+ * will be made for high layer (LWIP) and ethernet is responsible for
+ * freeing the buffer. Otherwise, high layer and ethernet share the
+ * same buffer and high layer is responsible for freeing the buffer.
*/
void
ethernetif_input(struct netif *netif, void *buffer, uint16_t len)
struct pbuf *p;
if(buffer== NULL || !netif_is_up(netif)) {
+#ifndef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
if (buffer) {
esp_eth_free_rx_buf(buffer);
}
+#endif
return;
}
#ifdef CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
if (p == NULL) {
- esp_eth_free_rx_buf(buffer);
return;
}
p->l2_owner = NULL;