mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
Merge branch 'cleanup/netif_glue' into 'master'
netif_glue: Removed deprecated esp_eth_set_default_handlers and esp_eth_clear_default_handlers Closes IDF-3736 See merge request espressif/esp-idf!15988
This commit is contained in:
@@ -1,16 +1,8 @@
|
||||
// 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-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "esp_eth.h"
|
||||
@@ -42,37 +34,6 @@ esp_eth_netif_glue_handle_t esp_eth_new_netif_glue(esp_eth_handle_t eth_hdl);
|
||||
*/
|
||||
esp_err_t esp_eth_del_netif_glue(esp_eth_netif_glue_handle_t eth_netif_glue);
|
||||
|
||||
/**
|
||||
* @brief Register default IP layer handlers for Ethernet
|
||||
*
|
||||
* @note: Ethernet handle might not yet properly initialized when setting up these default handlers
|
||||
* @warning: This function is deprecated and is kept here only for compatibility reasons. Registration
|
||||
* of default IP layer handlers for Ethernet is now handled automatically. Do not call this
|
||||
* function if you want to use multiple Ethernet instances at a time.
|
||||
*
|
||||
* @param[in] esp_netif esp network interface handle created for Ethernet driver
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL)
|
||||
* - ESP_OK: set default IP layer handlers successfully
|
||||
* - others: other failure occurred during register esp_event handler
|
||||
*/
|
||||
esp_err_t esp_eth_set_default_handlers(void *esp_netif) __attribute__ ((deprecated));
|
||||
|
||||
/**
|
||||
* @brief Unregister default IP layer handlers for Ethernet
|
||||
*
|
||||
* @warning: This function is deprecated and is kept here only for compatibility reasons. Unregistration
|
||||
* of default IP layer handlers for Ethernet is now handled automatically if not registered
|
||||
* by calling esp_eth_set_default_handlers.
|
||||
*
|
||||
* @param[in] esp_netif esp network interface handle created for Ethernet driver
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG: invalid parameter (esp_netif is NULL)
|
||||
* - ESP_OK: clear default IP layer handlers successfully
|
||||
* - others: other failure occurred during unregister esp_event handler
|
||||
*/
|
||||
esp_err_t esp_eth_clear_default_handlers(void *esp_netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,16 +1,8 @@
|
||||
// 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-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "esp_netif.h"
|
||||
#include "esp_eth.h"
|
||||
@@ -66,61 +58,6 @@ static esp_err_t esp_eth_post_attach(esp_netif_t *esp_netif, void *args)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_eth_clear_default_handlers(void *esp_netif)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(esp_netif, ESP_ERR_INVALID_ARG, TAG, "esp_netif handle can't be null");
|
||||
|
||||
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_START, esp_netif_action_start);
|
||||
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_STOP, esp_netif_action_stop);
|
||||
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_CONNECTED, esp_netif_action_connected);
|
||||
esp_event_handler_unregister(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, esp_netif_action_disconnected);
|
||||
esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, esp_netif_action_got_ip);
|
||||
|
||||
s_netif_glue_legacy_events_registered = false;
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_eth_set_default_handlers(void *esp_netif)
|
||||
{
|
||||
esp_err_t ret;
|
||||
|
||||
ESP_RETURN_ON_FALSE(esp_netif, ESP_ERR_INVALID_ARG, TAG, "esp_netif handle can't be null");
|
||||
|
||||
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_START, esp_netif_action_start, esp_netif);
|
||||
if (ret != ESP_OK) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_STOP, esp_netif_action_stop, esp_netif);
|
||||
if (ret != ESP_OK) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_CONNECTED, esp_netif_action_connected, esp_netif);
|
||||
if (ret != ESP_OK) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, esp_netif_action_disconnected, esp_netif);
|
||||
if (ret != ESP_OK) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, esp_netif_action_got_ip, esp_netif);
|
||||
if (ret != ESP_OK) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
s_netif_glue_legacy_events_registered = true;
|
||||
|
||||
return ESP_OK;
|
||||
|
||||
fail:
|
||||
esp_eth_clear_default_handlers(esp_netif);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void eth_action_start(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
|
||||
{
|
||||
esp_eth_handle_t eth_handle = *(esp_eth_handle_t *)event_data;
|
||||
|
@@ -186,7 +186,6 @@ static void ethernet_deinit(test_vfs_eth_network_t *network_hndls)
|
||||
TEST_ESP_OK(network_hndls->mac->del(network_hndls->mac));
|
||||
TEST_ESP_OK(esp_event_handler_unregister(IP_EVENT, IP_EVENT_ETH_GOT_IP, got_ip_event_handler));
|
||||
TEST_ESP_OK(esp_event_handler_unregister(ETH_EVENT, ESP_EVENT_ANY_ID, eth_event_handler));
|
||||
TEST_ESP_OK(esp_eth_clear_default_handlers(network_hndls->eth_netif));
|
||||
esp_netif_destroy(network_hndls->eth_netif);
|
||||
TEST_ESP_OK(esp_event_loop_delete_default());
|
||||
}
|
||||
|
@@ -41,3 +41,9 @@ As a result, the specific "chip number" functions calls were replaced by generic
|
||||
|
||||
* :cpp:func:`esp_eth_phy_new_ksz8041` and :cpp:func:`esp_eth_phy_new_ksz8081` were removed, use :cpp:func:`esp_eth_phy_new_ksz80xx` instead
|
||||
* :cpp:func:`esp_eth_phy_new_lan8720` was removed, use :cpp:func:`esp_eth_phy_new_lan87xx` instead
|
||||
|
||||
|
||||
ESP NETIF Glue Event Handlers
|
||||
-----------------------------
|
||||
``esp_eth_set_default_handlers()`` and ``esp_eth_clear_default_handlers()`` functions were removed. Registration of the default IP layer handlers for Ethernet is now handled automatically. If users have already followed the recommendation to fully initialize the Ethernet driver and network interface prior to registering their Ethernet/IP event handlers, then no action is required (except for deleting the affected functions). Otherwise, users should ensure that they register the user event handlers as the last thing prior to starting the Ethernet driver.
|
||||
|
||||
|
@@ -457,12 +457,10 @@ components/esp_common/include/esp_types.h
|
||||
components/esp_common/src/esp_err_to_name.c
|
||||
components/esp_common/test/test_attr.c
|
||||
components/esp_eth/include/esp_eth_mac.h
|
||||
components/esp_eth/include/esp_eth_netif_glue.h
|
||||
components/esp_eth/include/eth_phy_regs_struct.h
|
||||
components/esp_eth/src/dm9051.h
|
||||
components/esp_eth/src/esp_eth_mac_openeth.c
|
||||
components/esp_eth/src/esp_eth_mac_w5500.c
|
||||
components/esp_eth/src/esp_eth_netif_glue.c
|
||||
components/esp_eth/src/esp_eth_phy.c
|
||||
components/esp_eth/src/ksz8851.h
|
||||
components/esp_eth/src/openeth.h
|
||||
|
Reference in New Issue
Block a user