From 676a6159967f069556222a244fa55f14c0579db6 Mon Sep 17 00:00:00 2001
From: Gunar Schorcht <gunar@schorcht.net>
Date: Mon, 21 Jan 2019 15:25:43 +0100
Subject: [PATCH] cpu/esp32: fix of maximum frame length in esp_eth

Since complete MAC frames are handled, ETHERNET_MAX_LEN has to be used instead of ETHERNET_DATA_LEN for buffer sizes and length checks.
---
 cpu/esp32/esp-eth/esp_eth_netdev.c | 4 ++--
 cpu/esp32/esp-eth/esp_eth_netdev.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/cpu/esp32/esp-eth/esp_eth_netdev.c b/cpu/esp32/esp-eth/esp_eth_netdev.c
index d8cacc7ef4..bf641a7777 100644
--- a/cpu/esp32/esp-eth/esp_eth_netdev.c
+++ b/cpu/esp32/esp-eth/esp_eth_netdev.c
@@ -95,7 +95,7 @@ static esp_err_t IRAM_ATTR _eth_input_callback(void *buffer, uint16_t len, void
     DEBUG("%s: buf=%p len=%d eb=%p\n", __func__, buffer, len, eb);
 
     CHECK_PARAM_RET (buffer != NULL, -EINVAL);
-    CHECK_PARAM_RET (len <= ETHERNET_DATA_LEN, -EINVAL);
+    CHECK_PARAM_RET (len <= ETHERNET_MAX_LEN, -EINVAL);
 
     mutex_lock(&_esp_eth_dev.dev_lock);
 
@@ -198,7 +198,7 @@ static int _esp_eth_send(netdev_t *netdev, const iolist_t *iolist)
 
     /* load packet data into TX buffer */
     for (const iolist_t *iol = iolist; iol; iol = iol->iol_next) {
-        if (dev->tx_len + iol->iol_len > ETHERNET_DATA_LEN) {
+        if (dev->tx_len + iol->iol_len > ETHERNET_MAX_LEN) {
             mutex_unlock(&dev->dev_lock);
             return -EOVERFLOW;
         }
diff --git a/cpu/esp32/esp-eth/esp_eth_netdev.h b/cpu/esp32/esp-eth/esp_eth_netdev.h
index 0cb2254081..71fb8a090d 100644
--- a/cpu/esp32/esp-eth/esp_eth_netdev.h
+++ b/cpu/esp32/esp-eth/esp_eth_netdev.h
@@ -40,8 +40,8 @@ typedef struct
     uint16_t rx_len;                     /**< number of bytes received */
     uint16_t tx_len;                     /**< number of bytes in transmit buffer */
 
-    uint8_t  rx_buf[ETHERNET_DATA_LEN];  /**< receive buffer */
-    uint8_t  tx_buf[ETHERNET_DATA_LEN];  /**< transmit buffer */
+    uint8_t  rx_buf[ETHERNET_MAX_LEN];  /**< receive buffer */
+    uint8_t  tx_buf[ETHERNET_MAX_LEN];  /**< transmit buffer */
 
     uint32_t event;                     /**< received event */
     bool     link_up;                   /**< indicates whether link is up */
-- 
GitLab