Procházet zdrojové kódy

Merge branch 'bugfix/esp_netif_clean_deps' into 'master'

esp-netif: Make dependency on esp-eth optional

Closes IDF-4459

See merge request espressif/esp-idf!17980
David Čermák před 3 roky
rodič
revize
2c1f7a044e
35 změnil soubory, kde provedl 405 přidání a 424 odebrání
  1. 7 347
      components/esp_eth/include/esp_eth.h
  2. 333 0
      components/esp_eth/include/esp_eth_driver.h
  3. 1 1
      components/esp_eth/include/esp_eth_netif_glue.h
  4. 1 14
      components/esp_eth/src/esp_eth.c
  5. 1 1
      components/esp_eth/src/esp_eth_mac_dm9051.c
  6. 1 1
      components/esp_eth/src/esp_eth_mac_esp.c
  7. 2 2
      components/esp_eth/src/esp_eth_mac_ksz8851snl.c
  8. 1 1
      components/esp_eth/src/esp_eth_mac_openeth.c
  9. 6 14
      components/esp_eth/src/esp_eth_mac_w5500.c
  10. 1 1
      components/esp_eth/src/esp_eth_netif_glue.c
  11. 6 14
      components/esp_eth/src/esp_eth_phy.c
  12. 1 1
      components/esp_eth/src/esp_eth_phy_dm9051.c
  13. 1 1
      components/esp_eth/src/esp_eth_phy_dp83848.c
  14. 1 1
      components/esp_eth/src/esp_eth_phy_ip101.c
  15. 1 1
      components/esp_eth/src/esp_eth_phy_ksz80xx.c
  16. 2 2
      components/esp_eth/src/esp_eth_phy_ksz8851snl.c
  17. 1 1
      components/esp_eth/src/esp_eth_phy_lan87xx.c
  18. 1 1
      components/esp_eth/src/esp_eth_phy_rtl8201.c
  19. 1 1
      components/esp_eth/src/esp_eth_phy_w5500.c
  20. 11 2
      components/esp_netif/CMakeLists.txt
  21. 0 3
      components/esp_netif/esp_netif_defaults.c
  22. 0 4
      components/esp_netif/include/esp_netif.h
  23. 1 1
      components/esp_netif/test/CMakeLists.txt
  24. 1 2
      components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c
  25. 1 1
      components/lwip/port/esp32/netif/ethernetif.c
  26. 4 0
      components/mdns/CMakeLists.txt
  27. 4 0
      components/mdns/mdns.c
  28. 1 1
      components/mqtt/test/CMakeLists.txt
  29. 1 1
      examples/common_components/protocol_examples_common/CMakeLists.txt
  30. 1 0
      examples/common_components/protocol_examples_common/include/protocol_examples_common.h
  31. 1 1
      examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt
  32. 1 1
      examples/ethernet/eth2ap/main/ethernet_example_main.c
  33. 2 0
      examples/network/simple_sniffer/main/cmd_sniffer.h
  34. 7 0
      tools/ci/check_copyright_config.yaml
  35. 0 2
      tools/ci/check_copyright_ignore.txt

+ 7 - 347
components/esp_eth/include/esp_eth.h

@@ -1,356 +1,16 @@
 /*
- * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
 #pragma once
 
-#include "esp_eth_com.h"
-#include "esp_eth_mac.h"
-#include "esp_eth_phy.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
-* @brief Handle of Ethernet driver
-*
-*/
-typedef void *esp_eth_handle_t;
-
-/**
-* @brief Configuration of Ethernet driver
-*
-*/
-typedef struct {
-    /**
-    * @brief Ethernet MAC object
-    *
-    */
-    esp_eth_mac_t *mac;
-
-    /**
-    * @brief Ethernet PHY object
-    *
-    */
-    esp_eth_phy_t *phy;
-
-    /**
-    * @brief Period time of checking Ethernet link status
-    *
-    */
-    uint32_t check_link_period_ms;
-
-    /**
-    * @brief Input frame buffer to user's stack
-    *
-    * @param[in] eth_handle: handle of Ethernet driver
-    * @param[in] buffer: frame buffer that will get input to upper stack
-    * @param[in] length: length of the frame buffer
-    *
-    * @return
-    *      - ESP_OK: input frame buffer to upper stack successfully
-    *      - ESP_FAIL: error occurred when inputting buffer to upper stack
-    *
-    */
-    esp_err_t (*stack_input)(esp_eth_handle_t eth_handle, uint8_t *buffer, uint32_t length, void *priv);
-
-    /**
-    * @brief Callback function invoked when lowlevel initialization is finished
-    *
-    * @param[in] eth_handle: handle of Ethernet driver
-    *
-    * @return
-    *       - ESP_OK: process extra lowlevel initialization successfully
-    *       - ESP_FAIL: error occurred when processing extra lowlevel initialization
-    */
-    esp_err_t (*on_lowlevel_init_done)(esp_eth_handle_t eth_handle);
-
-    /**
-    * @brief Callback function invoked when lowlevel deinitialization is finished
-    *
-    * @param[in] eth_handle: handle of Ethernet driver
-    *
-    * @return
-    *       - ESP_OK: process extra lowlevel deinitialization successfully
-    *       - ESP_FAIL: error occurred when processing extra lowlevel deinitialization
-    */
-    esp_err_t (*on_lowlevel_deinit_done)(esp_eth_handle_t eth_handle);
-
-    /**
-    * @brief Read PHY register
-    *
-    * @note Usually the PHY register read/write function is provided by MAC (SMI interface),
-    *       but if the PHY device is managed by other interface (e.g. I2C), then user needs to
-    *       implement the corresponding read/write.
-    *       Setting this to NULL means your PHY device is managed by MAC's SMI interface.
-    *
-    * @param[in] eth_handle: handle of Ethernet driver
-    * @param[in] phy_addr: PHY chip address (0~31)
-    * @param[in] phy_reg: PHY register index code
-    * @param[out] reg_value: PHY register value
-    *
-    * @return
-    *      - ESP_OK: read PHY register successfully
-    *      - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
-    *      - ESP_ERR_TIMEOUT: read PHY register failed because of timeout
-    *      - ESP_FAIL: read PHY register failed because some other error occurred
-    */
-    esp_err_t (*read_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t *reg_value);
-
-    /**
-    * @brief Write PHY register
-    *
-    * @note Usually the PHY register read/write function is provided by MAC (SMI interface),
-    *       but if the PHY device is managed by other interface (e.g. I2C), then user needs to
-    *       implement the corresponding read/write.
-    *       Setting this to NULL means your PHY device is managed by MAC's SMI interface.
-    *
-    * @param[in] eth_handle: handle of Ethernet driver
-    * @param[in] phy_addr: PHY chip address (0~31)
-    * @param[in] phy_reg: PHY register index code
-    * @param[in] reg_value: PHY register value
-    *
-    * @return
-    *      - ESP_OK: write PHY register successfully
-    *      - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
-    *      - ESP_ERR_TIMEOUT: write PHY register failed because of timeout
-    *      - ESP_FAIL: write PHY register failed because some other error occurred
-    */
-    esp_err_t (*write_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t reg_value);
-} esp_eth_config_t;
-
-/**
-* @brief Command list for ioctl API
-*
-*/
-typedef enum {
-    ETH_CMD_G_MAC_ADDR,               /*!< Get MAC address */
-    ETH_CMD_S_MAC_ADDR,               /*!< Set MAC address */
-    ETH_CMD_G_PHY_ADDR,               /*!< Get PHY address */
-    ETH_CMD_S_PHY_ADDR,               /*!< Set PHY address */
-    ETH_CMD_G_AUTONEGO,               /*!< Get PHY Auto Negotiation */
-    ETH_CMD_S_AUTONEGO,               /*!< Set PHY Auto Negotiation */
-    ETH_CMD_G_SPEED,                  /*!< Get Speed */
-    ETH_CMD_S_SPEED,                  /*!< Set Speed */
-    ETH_CMD_S_PROMISCUOUS,            /*!< Set promiscuous mode */
-    ETH_CMD_S_FLOW_CTRL,              /*!< Set flow control */
-    ETH_CMD_G_DUPLEX_MODE,            /*!< Get Duplex mode */
-    ETH_CMD_S_DUPLEX_MODE,            /*!< Set Duplex mode */
-    ETH_CMD_S_PHY_LOOPBACK,           /*!< Set PHY loopback */
-
-    ETH_CMD_CUSTOM_MAC_CMDS = 0x0FFF, // Offset for start of MAC custom commands
-    ETH_CMD_CUSTOM_PHY_CMDS = 0x1FFF, // Offset for start of PHY custom commands
-} esp_eth_io_cmd_t;
-
 /**
- * @brief Default configuration for Ethernet driver
+ * Purpose of this file is to create a common header for the typical ethernet usecase,
+ * so using the ethernet driver and the default glue layer to its network interface.
  *
+ * If you prefer to create a custom network interface or use the Ethernet as a driver only,
+ * then it is recommended to include the "esp_eth_driver.h" only.
  */
-#define ETH_DEFAULT_CONFIG(emac, ephy)   \
-    {                                    \
-        .mac = emac,                     \
-        .phy = ephy,                     \
-        .check_link_period_ms = 2000,    \
-        .stack_input = NULL,             \
-        .on_lowlevel_init_done = NULL,   \
-        .on_lowlevel_deinit_done = NULL, \
-        .read_phy_reg = NULL,            \
-        .write_phy_reg = NULL,           \
-    }
-
-/**
-* @brief Install Ethernet driver
-*
-* @param[in]  config: configuration of the Ethernet driver
-* @param[out] out_hdl: handle of Ethernet driver
-*
-* @return
-*       - ESP_OK: install esp_eth driver successfully
-*       - ESP_ERR_INVALID_ARG: install esp_eth driver failed because of some invalid argument
-*       - ESP_ERR_NO_MEM: install esp_eth driver failed because there's no memory for driver
-*       - ESP_FAIL: install esp_eth driver failed because some other error occurred
-*/
-esp_err_t esp_eth_driver_install(const esp_eth_config_t *config, esp_eth_handle_t *out_hdl);
-
-/**
-* @brief Uninstall Ethernet driver
-* @note It's not recommended to uninstall Ethernet driver unless it won't get used any more in application code.
-*       To uninstall Ethernet driver, you have to make sure, all references to the driver are released.
-*       Ethernet driver can only be uninstalled successfully when reference counter equals to one.
-*
-* @param[in] hdl: handle of Ethernet driver
-*
-* @return
-*       - ESP_OK: uninstall esp_eth driver successfully
-*       - ESP_ERR_INVALID_ARG: uninstall esp_eth driver failed because of some invalid argument
-*       - ESP_ERR_INVALID_STATE: uninstall esp_eth driver failed because it has more than one reference
-*       - ESP_FAIL: uninstall esp_eth driver failed because some other error occurred
-*/
-esp_err_t esp_eth_driver_uninstall(esp_eth_handle_t hdl);
-
-/**
-* @brief Start Ethernet driver **ONLY** in standalone mode (i.e. without TCP/IP stack)
-*
-* @note This API will start driver state machine and internal software timer (for checking link status).
-*
-* @param[in] hdl handle of Ethernet driver
-*
-* @return
-*       - ESP_OK: start esp_eth driver successfully
-*       - ESP_ERR_INVALID_ARG: start esp_eth driver failed because of some invalid argument
-*       - ESP_ERR_INVALID_STATE: start esp_eth driver failed because driver has started already
-*       - ESP_FAIL: start esp_eth driver failed because some other error occurred
-*/
-esp_err_t esp_eth_start(esp_eth_handle_t hdl);
-
-/**
-* @brief Stop Ethernet driver
-*
-* @note This function does the oppsite operation of `esp_eth_start`.
-*
-* @param[in] hdl handle of Ethernet driver
-* @return
-*       - ESP_OK: stop esp_eth driver successfully
-*       - ESP_ERR_INVALID_ARG: stop esp_eth driver failed because of some invalid argument
-*       - ESP_ERR_INVALID_STATE: stop esp_eth driver failed because driver has not started yet
-*       - ESP_FAIL: stop esp_eth driver failed because some other error occurred
-*/
-esp_err_t esp_eth_stop(esp_eth_handle_t hdl);
-
-/**
-* @brief Update Ethernet data input path (i.e. specify where to pass the input buffer)
-*
-* @note After install driver, Ethernet still don't know where to deliver the input buffer.
-*       In fact, this API registers a callback function which get invoked when Ethernet received new packets.
-*
-* @param[in] hdl handle of Ethernet driver
-* @param[in] stack_input function pointer, which does the actual process on incoming packets
-* @param[in] priv private resource, which gets passed to `stack_input` callback without any modification
-* @return
-*       - ESP_OK: update input path successfully
-*       - ESP_ERR_INVALID_ARG: update input path failed because of some invalid argument
-*       - ESP_FAIL: update input path failed because some other error occurred
-*/
-esp_err_t esp_eth_update_input_path(
-    esp_eth_handle_t hdl,
-    esp_err_t (*stack_input)(esp_eth_handle_t hdl, uint8_t *buffer, uint32_t length, void *priv),
-    void *priv);
-
-/**
-* @brief General Transmit
-*
-* @param[in] hdl: handle of Ethernet driver
-* @param[in] buf: buffer of the packet to transfer
-* @param[in] length: length of the buffer to transfer
-*
-* @return
-*       - ESP_OK: transmit frame buffer successfully
-*       - ESP_ERR_INVALID_ARG: transmit frame buffer failed because of some invalid argument
-*       - ESP_ERR_INVALID_STATE: invalid driver state (e.i. driver is not started)
-*       - ESP_ERR_TIMEOUT: transmit frame buffer failed because HW was not get available in predefined period
-*       - ESP_FAIL: transmit frame buffer failed because some other error occurred
-*/
-esp_err_t esp_eth_transmit(esp_eth_handle_t hdl, void *buf, size_t length);
-
-/**
-* @brief Special Transmit with variable number of arguments
-*
-* @param[in] hdl handle of Ethernet driver
-* @param[in] argc number variable arguments
-* @param ... variable arguments
-* @return
-*       - ESP_OK: transmit successfull
-*       - ESP_ERR_INVALID_STATE: invalid driver state (e.i. driver is not started)
-*       - ESP_ERR_TIMEOUT: transmit frame buffer failed because HW was not get available in predefined period
-*       - ESP_FAIL: transmit frame buffer failed because some other error occurred
-*/
-esp_err_t esp_eth_transmit_vargs(esp_eth_handle_t hdl, uint32_t argc, ...);
-
-/**
-* @brief General Receive is deprecated and shall not be accessed from app code,
-*        as polling is not supported by Ethernet.
-*
-* @param[in] hdl: handle of Ethernet driver
-* @param[out] buf: buffer to preserve the received packet
-* @param[out] length: length of the received packet
-*
-* @note Before this function got invoked, the value of "length" should set by user, equals the size of buffer.
-*       After the function returned, the value of "length" means the real length of received data.
-* @note This API was exposed by accident, users should not use this API in their applications.
-*       Ethernet driver is interrupt driven, and doesn't support polling mode.
-*       Instead, users should register input callback with ``esp_eth_update_input_path``.
-*
-* @return
-*       - ESP_OK: receive frame buffer successfully
-*       - ESP_ERR_INVALID_ARG: receive frame buffer failed because of some invalid argument
-*       - ESP_ERR_INVALID_SIZE: input buffer size is not enough to hold the incoming data.
-*                               in this case, value of returned "length" indicates the real size of incoming data.
-*       - ESP_FAIL: receive frame buffer failed because some other error occurred
-*/
-esp_err_t esp_eth_receive(esp_eth_handle_t hdl, uint8_t *buf, uint32_t *length) __attribute__((deprecated("Ethernet driver is interrupt driven only, please register input callback with esp_eth_update_input_path")));
-
-/**
-* @brief Misc IO function of Etherent driver
-*
-* @param[in] hdl: handle of Ethernet driver
-* @param[in] cmd: IO control command
-* @param[in, out] data: address of data for `set` command or address where to store the data when used with `get` command
-*
-* @return
-*       - ESP_OK: process io command successfully
-*       - ESP_ERR_INVALID_ARG: process io command failed because of some invalid argument
-*       - ESP_FAIL: process io command failed because some other error occurred
-*       - ESP_ERR_NOT_SUPPORTED: requested feature is not supported
-*
-* The following common IO control commands are supported:
-* @li @c ETH_CMD_S_MAC_ADDR sets Ethernet interface MAC address. @c data argument is pointer to MAC address buffer with expected size of 6 bytes.
-* @li @c ETH_CMD_G_MAC_ADDR gets Ethernet interface MAC address. @c data argument is pointer to a buffer to which MAC address is to be copied. The buffer size must be at least 6 bytes.
-* @li @c ETH_CMD_S_PHY_ADDR sets PHY address in range of <0-31>. @c data argument is pointer to memory of uint32_t datatype from where the configuration option is read.
-* @li @c ETH_CMD_G_PHY_ADDR gets PHY address. @c data argument is pointer to memory of uint32_t datatype to which the PHY address is to be stored.
-* @li @c ETH_CMD_S_AUTONEGO enables or disables Ethernet link speed and duplex mode autonegotiation. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
-*                           Preconditions: Ethernet driver needs to be stopped.
-* @li @c ETH_CMD_G_AUTONEGO gets current configuration of the Ethernet link speed and duplex mode autonegotiation. @c data argument is pointer to memory of bool datatype to which the current configuration is to be stored.
-* @li @c ETH_CMD_S_SPEED sets the Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype from which the configuration option is read.
-*                           Preconditions: Ethernet driver needs to be stopped and auto-negotiation disabled.
-* @li @c ETH_CMD_G_SPEED gets current Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype to which the speed is to be stored.
-* @li @c ETH_CMD_S_PROMISCUOUS sets/resets Ethernet interface promiscuous mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
-* @li @c ETH_CMD_S_FLOW_CTRL sets/resets Ethernet interface flow control. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
-* @li @c ETH_CMD_S_DUPLEX_MODE sets the Ethernet duplex mode. @c data argument is pointer to memory of eth_duplex_t datatype from which the configuration option is read.
-*                            Preconditions: Ethernet driver needs to be stopped and auto-negotiation disabled.
-* @li @c ETH_CMD_G_DUPLEX_MODE gets current Ethernet link duplex mode.  @c data argument is pointer to memory of eth_duplex_t datatype to which the duplex mode is to be stored.
-* @li @c ETH_CMD_S_PHY_LOOPBACK sets/resets PHY to/from loopback mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
-*
-* @li Note that additional control commands may be available for specific MAC or PHY chips. Please consult specific MAC or PHY documentation or driver code.
-*/
-esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data);
-
-/**
-* @brief Increase Ethernet driver reference
-* @note Ethernet driver handle can be obtained by os timer, netif, etc.
-*       It's dangerous when thread A is using Ethernet but thread B uninstall the driver.
-*       Using reference counter can prevent such risk, but care should be taken, when you obtain Ethernet driver,
-*       this API must be invoked so that the driver won't be uninstalled during your using time.
-*
-*
-* @param[in] hdl: handle of Ethernet driver
-* @return
-*       - ESP_OK: increase reference successfully
-*       - ESP_ERR_INVALID_ARG: increase reference failed because of some invalid argument
-*/
-esp_err_t esp_eth_increase_reference(esp_eth_handle_t hdl);
-
-/**
-* @brief Decrease Ethernet driver reference
-*
-* @param[in] hdl: handle of Ethernet driver
-* @return
-*       - ESP_OK: increase reference successfully
-*       - ESP_ERR_INVALID_ARG: increase reference failed because of some invalid argument
-*/
-esp_err_t esp_eth_decrease_reference(esp_eth_handle_t hdl);
-
-#ifdef __cplusplus
-}
-#endif
+#include "esp_eth_driver.h"
+#include "esp_eth_netif_glue.h"

+ 333 - 0
components/esp_eth/include/esp_eth_driver.h

@@ -0,0 +1,333 @@
+/*
+ * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+#pragma once
+
+#include "esp_eth_com.h"
+#include "esp_eth_mac.h"
+#include "esp_eth_phy.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @brief Handle of Ethernet driver
+*
+*/
+typedef void *esp_eth_handle_t;
+
+/**
+* @brief Configuration of Ethernet driver
+*
+*/
+typedef struct {
+    /**
+    * @brief Ethernet MAC object
+    *
+    */
+    esp_eth_mac_t *mac;
+
+    /**
+    * @brief Ethernet PHY object
+    *
+    */
+    esp_eth_phy_t *phy;
+
+    /**
+    * @brief Period time of checking Ethernet link status
+    *
+    */
+    uint32_t check_link_period_ms;
+
+    /**
+    * @brief Input frame buffer to user's stack
+    *
+    * @param[in] eth_handle: handle of Ethernet driver
+    * @param[in] buffer: frame buffer that will get input to upper stack
+    * @param[in] length: length of the frame buffer
+    *
+    * @return
+    *      - ESP_OK: input frame buffer to upper stack successfully
+    *      - ESP_FAIL: error occurred when inputting buffer to upper stack
+    *
+    */
+    esp_err_t (*stack_input)(esp_eth_handle_t eth_handle, uint8_t *buffer, uint32_t length, void *priv);
+
+    /**
+    * @brief Callback function invoked when lowlevel initialization is finished
+    *
+    * @param[in] eth_handle: handle of Ethernet driver
+    *
+    * @return
+    *       - ESP_OK: process extra lowlevel initialization successfully
+    *       - ESP_FAIL: error occurred when processing extra lowlevel initialization
+    */
+    esp_err_t (*on_lowlevel_init_done)(esp_eth_handle_t eth_handle);
+
+    /**
+    * @brief Callback function invoked when lowlevel deinitialization is finished
+    *
+    * @param[in] eth_handle: handle of Ethernet driver
+    *
+    * @return
+    *       - ESP_OK: process extra lowlevel deinitialization successfully
+    *       - ESP_FAIL: error occurred when processing extra lowlevel deinitialization
+    */
+    esp_err_t (*on_lowlevel_deinit_done)(esp_eth_handle_t eth_handle);
+
+    /**
+    * @brief Read PHY register
+    *
+    * @note Usually the PHY register read/write function is provided by MAC (SMI interface),
+    *       but if the PHY device is managed by other interface (e.g. I2C), then user needs to
+    *       implement the corresponding read/write.
+    *       Setting this to NULL means your PHY device is managed by MAC's SMI interface.
+    *
+    * @param[in] eth_handle: handle of Ethernet driver
+    * @param[in] phy_addr: PHY chip address (0~31)
+    * @param[in] phy_reg: PHY register index code
+    * @param[out] reg_value: PHY register value
+    *
+    * @return
+    *      - ESP_OK: read PHY register successfully
+    *      - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
+    *      - ESP_ERR_TIMEOUT: read PHY register failed because of timeout
+    *      - ESP_FAIL: read PHY register failed because some other error occurred
+    */
+    esp_err_t (*read_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t *reg_value);
+
+    /**
+    * @brief Write PHY register
+    *
+    * @note Usually the PHY register read/write function is provided by MAC (SMI interface),
+    *       but if the PHY device is managed by other interface (e.g. I2C), then user needs to
+    *       implement the corresponding read/write.
+    *       Setting this to NULL means your PHY device is managed by MAC's SMI interface.
+    *
+    * @param[in] eth_handle: handle of Ethernet driver
+    * @param[in] phy_addr: PHY chip address (0~31)
+    * @param[in] phy_reg: PHY register index code
+    * @param[in] reg_value: PHY register value
+    *
+    * @return
+    *      - ESP_OK: write PHY register successfully
+    *      - ESP_ERR_INVALID_ARG: read PHY register failed because of invalid argument
+    *      - ESP_ERR_TIMEOUT: write PHY register failed because of timeout
+    *      - ESP_FAIL: write PHY register failed because some other error occurred
+    */
+    esp_err_t (*write_phy_reg)(esp_eth_handle_t eth_handle, uint32_t phy_addr, uint32_t phy_reg, uint32_t reg_value);
+} esp_eth_config_t;
+
+/**
+* @brief Command list for ioctl API
+*
+*/
+typedef enum {
+    ETH_CMD_G_MAC_ADDR,               /*!< Get MAC address */
+    ETH_CMD_S_MAC_ADDR,               /*!< Set MAC address */
+    ETH_CMD_G_PHY_ADDR,               /*!< Get PHY address */
+    ETH_CMD_S_PHY_ADDR,               /*!< Set PHY address */
+    ETH_CMD_G_AUTONEGO,               /*!< Get PHY Auto Negotiation */
+    ETH_CMD_S_AUTONEGO,               /*!< Set PHY Auto Negotiation */
+    ETH_CMD_G_SPEED,                  /*!< Get Speed */
+    ETH_CMD_S_SPEED,                  /*!< Set Speed */
+    ETH_CMD_S_PROMISCUOUS,            /*!< Set promiscuous mode */
+    ETH_CMD_S_FLOW_CTRL,              /*!< Set flow control */
+    ETH_CMD_G_DUPLEX_MODE,            /*!< Get Duplex mode */
+    ETH_CMD_S_DUPLEX_MODE,            /*!< Set Duplex mode */
+    ETH_CMD_S_PHY_LOOPBACK,           /*!< Set PHY loopback */
+
+    ETH_CMD_CUSTOM_MAC_CMDS = 0x0FFF, // Offset for start of MAC custom commands
+    ETH_CMD_CUSTOM_PHY_CMDS = 0x1FFF, // Offset for start of PHY custom commands
+} esp_eth_io_cmd_t;
+
+/**
+ * @brief Default configuration for Ethernet driver
+ *
+ */
+#define ETH_DEFAULT_CONFIG(emac, ephy)   \
+    {                                    \
+        .mac = emac,                     \
+        .phy = ephy,                     \
+        .check_link_period_ms = 2000,    \
+        .stack_input = NULL,             \
+        .on_lowlevel_init_done = NULL,   \
+        .on_lowlevel_deinit_done = NULL, \
+        .read_phy_reg = NULL,            \
+        .write_phy_reg = NULL,           \
+    }
+
+/**
+* @brief Install Ethernet driver
+*
+* @param[in]  config: configuration of the Ethernet driver
+* @param[out] out_hdl: handle of Ethernet driver
+*
+* @return
+*       - ESP_OK: install esp_eth driver successfully
+*       - ESP_ERR_INVALID_ARG: install esp_eth driver failed because of some invalid argument
+*       - ESP_ERR_NO_MEM: install esp_eth driver failed because there's no memory for driver
+*       - ESP_FAIL: install esp_eth driver failed because some other error occurred
+*/
+esp_err_t esp_eth_driver_install(const esp_eth_config_t *config, esp_eth_handle_t *out_hdl);
+
+/**
+* @brief Uninstall Ethernet driver
+* @note It's not recommended to uninstall Ethernet driver unless it won't get used any more in application code.
+*       To uninstall Ethernet driver, you have to make sure, all references to the driver are released.
+*       Ethernet driver can only be uninstalled successfully when reference counter equals to one.
+*
+* @param[in] hdl: handle of Ethernet driver
+*
+* @return
+*       - ESP_OK: uninstall esp_eth driver successfully
+*       - ESP_ERR_INVALID_ARG: uninstall esp_eth driver failed because of some invalid argument
+*       - ESP_ERR_INVALID_STATE: uninstall esp_eth driver failed because it has more than one reference
+*       - ESP_FAIL: uninstall esp_eth driver failed because some other error occurred
+*/
+esp_err_t esp_eth_driver_uninstall(esp_eth_handle_t hdl);
+
+/**
+* @brief Start Ethernet driver **ONLY** in standalone mode (i.e. without TCP/IP stack)
+*
+* @note This API will start driver state machine and internal software timer (for checking link status).
+*
+* @param[in] hdl handle of Ethernet driver
+*
+* @return
+*       - ESP_OK: start esp_eth driver successfully
+*       - ESP_ERR_INVALID_ARG: start esp_eth driver failed because of some invalid argument
+*       - ESP_ERR_INVALID_STATE: start esp_eth driver failed because driver has started already
+*       - ESP_FAIL: start esp_eth driver failed because some other error occurred
+*/
+esp_err_t esp_eth_start(esp_eth_handle_t hdl);
+
+/**
+* @brief Stop Ethernet driver
+*
+* @note This function does the oppsite operation of `esp_eth_start`.
+*
+* @param[in] hdl handle of Ethernet driver
+* @return
+*       - ESP_OK: stop esp_eth driver successfully
+*       - ESP_ERR_INVALID_ARG: stop esp_eth driver failed because of some invalid argument
+*       - ESP_ERR_INVALID_STATE: stop esp_eth driver failed because driver has not started yet
+*       - ESP_FAIL: stop esp_eth driver failed because some other error occurred
+*/
+esp_err_t esp_eth_stop(esp_eth_handle_t hdl);
+
+/**
+* @brief Update Ethernet data input path (i.e. specify where to pass the input buffer)
+*
+* @note After install driver, Ethernet still don't know where to deliver the input buffer.
+*       In fact, this API registers a callback function which get invoked when Ethernet received new packets.
+*
+* @param[in] hdl handle of Ethernet driver
+* @param[in] stack_input function pointer, which does the actual process on incoming packets
+* @param[in] priv private resource, which gets passed to `stack_input` callback without any modification
+* @return
+*       - ESP_OK: update input path successfully
+*       - ESP_ERR_INVALID_ARG: update input path failed because of some invalid argument
+*       - ESP_FAIL: update input path failed because some other error occurred
+*/
+esp_err_t esp_eth_update_input_path(
+    esp_eth_handle_t hdl,
+    esp_err_t (*stack_input)(esp_eth_handle_t hdl, uint8_t *buffer, uint32_t length, void *priv),
+    void *priv);
+
+/**
+* @brief General Transmit
+*
+* @param[in] hdl: handle of Ethernet driver
+* @param[in] buf: buffer of the packet to transfer
+* @param[in] length: length of the buffer to transfer
+*
+* @return
+*       - ESP_OK: transmit frame buffer successfully
+*       - ESP_ERR_INVALID_ARG: transmit frame buffer failed because of some invalid argument
+*       - ESP_ERR_INVALID_STATE: invalid driver state (e.i. driver is not started)
+*       - ESP_ERR_TIMEOUT: transmit frame buffer failed because HW was not get available in predefined period
+*       - ESP_FAIL: transmit frame buffer failed because some other error occurred
+*/
+esp_err_t esp_eth_transmit(esp_eth_handle_t hdl, void *buf, size_t length);
+
+/**
+* @brief Special Transmit with variable number of arguments
+*
+* @param[in] hdl handle of Ethernet driver
+* @param[in] argc number variable arguments
+* @param ... variable arguments
+* @return
+*       - ESP_OK: transmit successfull
+*       - ESP_ERR_INVALID_STATE: invalid driver state (e.i. driver is not started)
+*       - ESP_ERR_TIMEOUT: transmit frame buffer failed because HW was not get available in predefined period
+*       - ESP_FAIL: transmit frame buffer failed because some other error occurred
+*/
+esp_err_t esp_eth_transmit_vargs(esp_eth_handle_t hdl, uint32_t argc, ...);
+
+/**
+* @brief Misc IO function of Etherent driver
+*
+* @param[in] hdl: handle of Ethernet driver
+* @param[in] cmd: IO control command
+* @param[in, out] data: address of data for `set` command or address where to store the data when used with `get` command
+*
+* @return
+*       - ESP_OK: process io command successfully
+*       - ESP_ERR_INVALID_ARG: process io command failed because of some invalid argument
+*       - ESP_FAIL: process io command failed because some other error occurred
+*       - ESP_ERR_NOT_SUPPORTED: requested feature is not supported
+*
+* The following common IO control commands are supported:
+* @li @c ETH_CMD_S_MAC_ADDR sets Ethernet interface MAC address. @c data argument is pointer to MAC address buffer with expected size of 6 bytes.
+* @li @c ETH_CMD_G_MAC_ADDR gets Ethernet interface MAC address. @c data argument is pointer to a buffer to which MAC address is to be copied. The buffer size must be at least 6 bytes.
+* @li @c ETH_CMD_S_PHY_ADDR sets PHY address in range of <0-31>. @c data argument is pointer to memory of uint32_t datatype from where the configuration option is read.
+* @li @c ETH_CMD_G_PHY_ADDR gets PHY address. @c data argument is pointer to memory of uint32_t datatype to which the PHY address is to be stored.
+* @li @c ETH_CMD_S_AUTONEGO enables or disables Ethernet link speed and duplex mode autonegotiation. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
+*                           Preconditions: Ethernet driver needs to be stopped.
+* @li @c ETH_CMD_G_AUTONEGO gets current configuration of the Ethernet link speed and duplex mode autonegotiation. @c data argument is pointer to memory of bool datatype to which the current configuration is to be stored.
+* @li @c ETH_CMD_S_SPEED sets the Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype from which the configuration option is read.
+*                           Preconditions: Ethernet driver needs to be stopped and auto-negotiation disabled.
+* @li @c ETH_CMD_G_SPEED gets current Ethernet link speed. @c data argument is pointer to memory of eth_speed_t datatype to which the speed is to be stored.
+* @li @c ETH_CMD_S_PROMISCUOUS sets/resets Ethernet interface promiscuous mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
+* @li @c ETH_CMD_S_FLOW_CTRL sets/resets Ethernet interface flow control. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
+* @li @c ETH_CMD_S_DUPLEX_MODE sets the Ethernet duplex mode. @c data argument is pointer to memory of eth_duplex_t datatype from which the configuration option is read.
+*                            Preconditions: Ethernet driver needs to be stopped and auto-negotiation disabled.
+* @li @c ETH_CMD_G_DUPLEX_MODE gets current Ethernet link duplex mode.  @c data argument is pointer to memory of eth_duplex_t datatype to which the duplex mode is to be stored.
+* @li @c ETH_CMD_S_PHY_LOOPBACK sets/resets PHY to/from loopback mode. @c data argument is pointer to memory of bool datatype from which the configuration option is read.
+*
+* @li Note that additional control commands may be available for specific MAC or PHY chips. Please consult specific MAC or PHY documentation or driver code.
+*/
+esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data);
+
+/**
+* @brief Increase Ethernet driver reference
+* @note Ethernet driver handle can be obtained by os timer, netif, etc.
+*       It's dangerous when thread A is using Ethernet but thread B uninstall the driver.
+*       Using reference counter can prevent such risk, but care should be taken, when you obtain Ethernet driver,
+*       this API must be invoked so that the driver won't be uninstalled during your using time.
+*
+*
+* @param[in] hdl: handle of Ethernet driver
+* @return
+*       - ESP_OK: increase reference successfully
+*       - ESP_ERR_INVALID_ARG: increase reference failed because of some invalid argument
+*/
+esp_err_t esp_eth_increase_reference(esp_eth_handle_t hdl);
+
+/**
+* @brief Decrease Ethernet driver reference
+*
+* @param[in] hdl: handle of Ethernet driver
+* @return
+*       - ESP_OK: increase reference successfully
+*       - ESP_ERR_INVALID_ARG: increase reference failed because of some invalid argument
+*/
+esp_err_t esp_eth_decrease_reference(esp_eth_handle_t hdl);
+
+#ifdef __cplusplus
+}
+#endif

+ 1 - 1
components/esp_eth/include/esp_eth_netif_glue.h

@@ -5,7 +5,7 @@
  */
 #pragma once
 
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 
 #ifdef __cplusplus
 extern "C" {

+ 1 - 14
components/esp_eth/src/esp_eth.c

@@ -8,7 +8,7 @@
 #include <stdatomic.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_event.h"
 #include "esp_heap_caps.h"
 #include "esp_timer.h"
@@ -388,19 +388,6 @@ err:
     return ret;
 }
 
-esp_err_t esp_eth_receive(esp_eth_handle_t hdl, uint8_t *buf, uint32_t *length)
-{
-    esp_err_t ret = ESP_OK;
-    esp_eth_driver_t *eth_driver = (esp_eth_driver_t *)hdl;
-    ESP_GOTO_ON_FALSE(buf && length, ESP_ERR_INVALID_ARG, err, TAG, "can't set buf and length to null");
-    ESP_GOTO_ON_FALSE(*length > 60, ESP_ERR_INVALID_ARG, err, TAG, "length can't be less than 60");
-    ESP_GOTO_ON_FALSE(eth_driver, ESP_ERR_INVALID_ARG, err, TAG, "ethernet driver handle can't be null");
-    esp_eth_mac_t *mac = eth_driver->mac;
-    ret = mac->receive(mac, buf, length);
-err:
-    return ret;
-}
-
 esp_err_t esp_eth_ioctl(esp_eth_handle_t hdl, esp_eth_io_cmd_t cmd, void *data)
 {
     esp_err_t ret = ESP_OK;

+ 1 - 1
components/esp_eth/src/esp_eth_mac_dm9051.c

@@ -12,7 +12,7 @@
 #include "esp_attr.h"
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_timer.h"
 #include "esp_system.h"
 #include "esp_intr_alloc.h"

+ 1 - 1
components/esp_eth/src/esp_eth_mac_esp.c

@@ -12,7 +12,7 @@
 #include "esp_attr.h"
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_pm.h"
 #include "esp_mac.h"
 #include "esp_heap_caps.h"

+ 2 - 2
components/esp_eth/src/esp_eth_mac_ksz8851snl.c

@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier: MIT
  *
- * SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
  */
 
 #include <string.h>
@@ -15,7 +15,7 @@
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/semphr.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "ksz8851.h"
 
 

+ 1 - 1
components/esp_eth/src/esp_eth_mac_openeth.c

@@ -19,7 +19,7 @@
 #include <sys/param.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_intr_alloc.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 6 - 14
components/esp_eth/src/esp_eth_mac_w5500.c

@@ -1,16 +1,8 @@
-// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 #include <string.h>
 #include <stdlib.h>
 #include <sys/cdefs.h>
@@ -19,7 +11,7 @@
 #include "esp_attr.h"
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_system.h"
 #include "esp_intr_alloc.h"
 #include "esp_heap_caps.h"

+ 1 - 1
components/esp_eth/src/esp_eth_netif_glue.c

@@ -5,7 +5,7 @@
  */
 #include <stdlib.h>
 #include "esp_netif.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_eth_netif_glue.h"
 #include "esp_event.h"
 #include "esp_log.h"

+ 6 - 14
components/esp_eth/src/esp_eth_phy.c

@@ -1,20 +1,12 @@
-// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+/*
+ * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
 #include <string.h>
 #include <stdlib.h>
 #include "esp_log.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 
 static const char *TAG = "esp_eth.phy";

+ 1 - 1
components/esp_eth/src/esp_eth_phy_dm9051.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 1 - 1
components/esp_eth/src/esp_eth_phy_dp83848.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 1 - 1
components/esp_eth/src/esp_eth_phy_ip101.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 1 - 1
components/esp_eth/src/esp_eth_phy_ksz80xx.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 2 - 2
components/esp_eth/src/esp_eth_phy_ksz8851snl.c

@@ -3,7 +3,7 @@
  *
  * SPDX-License-Identifier: MIT
  *
- * SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
  */
 #include <stdlib.h>
 #include "esp_check.h"
@@ -13,7 +13,7 @@
 #include "esp_rom_gpio.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "ksz8851.h"
 
 

+ 1 - 1
components/esp_eth/src/esp_eth_phy_lan87xx.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 1 - 1
components/esp_eth/src/esp_eth_phy_rtl8201.c

@@ -9,7 +9,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "eth_phy_regs_struct.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"

+ 1 - 1
components/esp_eth/src/esp_eth_phy_w5500.c

@@ -8,7 +8,7 @@
 #include <sys/cdefs.h>
 #include "esp_log.h"
 #include "esp_check.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "driver/gpio.h"

+ 11 - 2
components/esp_netif/CMakeLists.txt

@@ -10,7 +10,6 @@ set(srcs
     "esp_netif_handlers.c"
     "esp_netif_objects.c"
     "esp_netif_defaults.c"
-    "vfs_l2tap/esp_vfs_l2tap.c"
     "lwip/esp_netif_lwip.c"
     "lwip/esp_netif_lwip_defaults.c"
     "lwip/esp_netif_sta_list.c")
@@ -33,7 +32,17 @@ list(APPEND srcs
     "loopback/esp_netif_loopback.c")
 endif()
 
+if(CONFIG_ESP_NETIF_L2_TAP)
+list(APPEND srcs
+    "vfs_l2tap/esp_vfs_l2tap.c")
+endif()
+
 idf_component_register(SRCS "${srcs}"
                     INCLUDE_DIRS "${include_dirs}"
                     PRIV_INCLUDE_DIRS "${priv_include_dirs}"
-                    REQUIRES lwip esp_eth)
+                    REQUIRES lwip)
+
+
+if(CONFIG_ESP_NETIF_L2_TAP)
+idf_component_optional_requires(PRIVATE esp_eth)
+endif()

+ 0 - 3
components/esp_netif/esp_netif_defaults.c

@@ -6,9 +6,6 @@
 
 #include "esp_netif.h"
 #include "esp_wifi_default.h"
-#if CONFIG_ETH_ENABLED
-#include "esp_eth.h"
-#endif
 
 //
 // Purpose of this module is to provide

+ 0 - 4
components/esp_netif/include/esp_netif.h

@@ -14,10 +14,6 @@
 #include "esp_netif_types.h"
 #include "esp_netif_defaults.h"
 
-#ifdef CONFIG_ETH_ENABLED
-#include "esp_eth_netif_glue.h"
-#endif
-
 
 #ifdef __cplusplus
 extern "C" {

+ 1 - 1
components/esp_netif/test/CMakeLists.txt

@@ -1,3 +1,3 @@
 idf_component_register(SRC_DIRS "."
                     PRIV_INCLUDE_DIRS  "../private_include" "."
-                    PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver)
+                    PRIV_REQUIRES cmock test_utils esp_netif nvs_flash driver esp_eth)

+ 1 - 2
components/esp_netif/vfs_l2tap/esp_vfs_l2tap.c

@@ -19,12 +19,12 @@
 #include "esp_log.h"
 #include "esp_check.h"
 #include "esp_netif.h"
+#include "esp_eth_driver.h"
 
 #include "freertos/FreeRTOS.h"
 #include "freertos/semphr.h"
 #include "freertos/queue.h"
 
-#if CONFIG_ESP_NETIF_L2_TAP
 
 #define INVALID_FD          (-1)
 
@@ -624,4 +624,3 @@ esp_err_t esp_vfs_l2tap_intf_unregister(const char *base_path)
 
     return ESP_OK;
 }
-#endif // CONFIG_ESP_NETIF_L2_TAP

+ 1 - 1
components/lwip/port/esp32/netif/ethernetif.c

@@ -48,7 +48,7 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_netif.h"
 #include "esp_netif_net_stack.h"
 #include "esp_compiler.h"

+ 4 - 0
components/mdns/CMakeLists.txt

@@ -20,3 +20,7 @@ idf_component_register(
         PRIV_INCLUDE_DIRS "private_include"
         REQUIRES ${dependencies}
         PRIV_REQUIRES ${private_dependencies})
+
+if(CONFIG_ETH_ENABLED)
+    idf_component_optional_requires(PRIVATE esp_eth)
+endif()

+ 4 - 0
components/mdns/mdns.c

@@ -17,6 +17,10 @@
 #include "mdns_networking.h"
 #include "esp_log.h"
 #include "esp_random.h"
+#if CONFIG_ETH_ENABLED
+#include "esp_eth.h"
+#endif
+
 
 #ifdef MDNS_ENABLE_DEBUG
 void mdns_debug_packet(const uint8_t * data, size_t len);

+ 1 - 1
components/mqtt/test/CMakeLists.txt

@@ -1,2 +1,2 @@
 idf_component_register(SRC_DIRS "."
-                    PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update)
+                    PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update esp_eth)

+ 1 - 1
examples/common_components/protocol_examples_common/CMakeLists.txt

@@ -1,4 +1,4 @@
 idf_component_register(SRCS "connect.c" "stdin_out.c" "addr_from_stdin.c"
                     INCLUDE_DIRS "include"
-                    PRIV_REQUIRES esp_netif driver
+                    PRIV_REQUIRES esp_netif driver esp_eth
                     )

+ 1 - 0
examples/common_components/protocol_examples_common/include/protocol_examples_common.h

@@ -15,6 +15,7 @@ extern "C" {
 
 #include "esp_err.h"
 #include "esp_netif.h"
+#include "esp_eth.h"
 
 #ifdef CONFIG_EXAMPLE_CONNECT_ETHERNET
 #define EXAMPLE_INTERFACE get_example_netif()

+ 1 - 1
examples/ethernet/enc28j60/components/eth_enc28j60/CMakeLists.txt

@@ -1,4 +1,4 @@
 idf_component_register(SRCS "esp_eth_mac_enc28j60.c"
                             "esp_eth_phy_enc28j60.c"
-                       PRIV_REQUIRES driver
+                       PRIV_REQUIRES driver esp_eth
                        INCLUDE_DIRS ".")

+ 1 - 1
examples/ethernet/eth2ap/main/ethernet_example_main.c

@@ -14,7 +14,7 @@
 #include "freertos/queue.h"
 #include "esp_event.h"
 #include "esp_log.h"
-#include "esp_eth.h"
+#include "esp_eth_driver.h"
 #include "esp_wifi.h"
 #include "nvs_flash.h"
 #include "esp_private/wifi.h"

+ 2 - 0
examples/network/simple_sniffer/main/cmd_sniffer.h

@@ -8,6 +8,8 @@
 */
 #pragma once
 
+#include "esp_eth_driver.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif

+ 7 - 0
tools/ci/check_copyright_config.yaml

@@ -81,6 +81,13 @@ freertos_component:
     - Apache-2.0    #Files added to the freertos added by us
     - MIT           #FreeRTOS sources and port files
 
+ethernet_component:
+  include:
+    - 'components/esp_eth/**'
+  allowed_licenses:
+    - Apache-2.0
+    - MIT           # To allow contributed drivers
+
 systemview:
   include:
     - 'components/app_trace/sys_view'

+ 0 - 2
tools/ci/check_copyright_ignore.txt

@@ -419,8 +419,6 @@ components/esp32/include/rom/tjpgd.h
 components/esp32/include/rom/uart.h
 components/esp_eth/include/eth_phy_regs_struct.h
 components/esp_eth/src/dm9051.h
-components/esp_eth/src/esp_eth_mac_w5500.c
-components/esp_eth/src/esp_eth_phy.c
 components/esp_eth/src/ksz8851.h
 components/esp_eth/src/openeth.h
 components/esp_eth/src/w5500.h