diff --git a/components/ethernet/emac_dev.c b/components/ethernet/emac_dev.c index 9ec1822bb5..c439f8a085 100644 --- a/components/ethernet/emac_dev.c +++ b/components/ethernet/emac_dev.c @@ -111,5 +111,4 @@ void emac_mac_init(void) REG_SET_BIT(EMAC_GMACCONFIG_REG, EMAC_EMACDUPLEX); REG_SET_BIT(EMAC_GMACCONFIG_REG, EMAC_EMACMII); REG_CLR_BIT(EMAC_GMACCONFIG_REG, EMAC_EMACFESPEED); - REG_SET_BIT(EMAC_GMACFF_REG, EMAC_PMODE); } diff --git a/components/ethernet/emac_main.c b/components/ethernet/emac_main.c index b57477de2d..5f91f6eba6 100644 --- a/components/ethernet/emac_main.c +++ b/components/ethernet/emac_main.c @@ -104,9 +104,6 @@ esp_err_t esp_eth_set_mac(const uint8_t mac[6]) static void emac_setup_tx_desc(struct dma_extended_desc *tx_desc, uint32_t size) { tx_desc->basic.desc1 = size & 0xfff; - tx_desc->basic.desc0 = EMAC_DESC_INT_COMPL | EMAC_DESC_LAST_SEGMENT | - EMAC_DESC_FIRST_SEGMENT | - EMAC_DESC_SECOND_ADDR_CHAIN; tx_desc->basic.desc0 = EMAC_DESC_TX_OWN | EMAC_DESC_INT_COMPL | EMAC_DESC_LAST_SEGMENT | EMAC_DESC_FIRST_SEGMENT | EMAC_DESC_SECOND_ADDR_CHAIN; @@ -292,7 +289,7 @@ static void emac_set_user_config_data(eth_config_t *config) #if DMA_RX_BUF_NUM > 9 emac_config.emac_flow_ctrl_enable = config->flow_ctrl_enable; #else - if(config->flow_ctrl_enable == true) { + if (config->flow_ctrl_enable == true) { ESP_LOGE(TAG, "Can only configure flow_ctrl_enable==true if DMA_RX_BUF_NUM in menuconfig is >9. Disabling flow control."); } emac_config.emac_flow_ctrl_enable = false; @@ -630,10 +627,10 @@ static void IRAM_ATTR emac_process_intr(void *arg) static void emac_set_macaddr_reg(void) { - REG_SET_FIELD(EMAC_ADDR0HIGH_REG, EMAC_ADDRESS0_HI, (emac_config.macaddr[0] << 8) | (emac_config.macaddr[1])); - REG_WRITE(EMAC_ADDR0LOW_REG, (emac_config.macaddr[2] << 24) | - (emac_config.macaddr[3] << 16) | (emac_config.macaddr[4] << 8) | - (emac_config.macaddr[5])); + REG_SET_FIELD(EMAC_ADDR0HIGH_REG, EMAC_ADDRESS0_HI, (emac_config.macaddr[5] << 8) | (emac_config.macaddr[4])); + REG_WRITE(EMAC_ADDR0LOW_REG, (emac_config.macaddr[3] << 24) | + (emac_config.macaddr[2] << 16) | (emac_config.macaddr[1] << 8) | + (emac_config.macaddr[0])); } static void emac_check_phy_init(void) diff --git a/components/ethernet/include/esp_eth.h b/components/ethernet/include/esp_eth.h index 3d16ffa5b6..0d39b8efaa 100644 --- a/components/ethernet/include/esp_eth.h +++ b/components/ethernet/include/esp_eth.h @@ -260,14 +260,6 @@ static inline esp_err_t esp_eth_smi_wait_set(uint32_t reg_num, uint16_t value_ma */ void esp_eth_free_rx_buf(void *buf); -/** - * @brief Get mac of ethernet interface. - * - * @param[out] mac: store mac of the interface. - * - */ -void esp_eth_get_mac(uint8_t mac[6]); - /** * @brief Set mac of ethernet interface. * diff --git a/components/lwip/port/esp32/netif/ethernetif.c b/components/lwip/port/esp32/netif/ethernetif.c index 9189c03a91..4cea6a38ff 100644 --- a/components/lwip/port/esp32/netif/ethernetif.c +++ b/components/lwip/port/esp32/netif/ethernetif.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -64,7 +64,7 @@ */ static void ethernet_low_level_init(struct netif *netif) -{ +{ /* set MAC hardware address length */ netif->hwaddr_len = ETHARP_HWADDR_LEN; @@ -103,40 +103,35 @@ ethernet_low_level_init(struct netif *netif) * to become availale since the stack doesn't retry to send a packet * dropped because of memory failure (except for the TCP timers). */ -static err_t +static err_t ESP_IRAM_ATTR ethernet_low_level_output(struct netif *netif, struct pbuf *p) { - struct pbuf *q; + struct pbuf *q = p; esp_interface_t eth_if = tcpip_adapter_get_esp_if(netif); + err_t ret; if (eth_if != ESP_IF_ETH) { - LWIP_DEBUGF(NETIF_DEBUG,("eth_if=%d netif=%p pbuf=%p len=%d\n", eth_if, netif, p, p->len)); + LWIP_DEBUGF(NETIF_DEBUG, ("eth_if=%d netif=%p pbuf=%p len=%d\n", eth_if, netif, p, p->len)); return ERR_IF; } -#if ESP_LWIP - q = p; - u16_t pbuf_x_len = 0; - pbuf_x_len = q->len; - if(q->next !=NULL) { - //char cnt = 0; - struct pbuf *tmp = q->next; - while(tmp != NULL) { - memcpy( (u8_t *)( (u8_t *)(q->payload) + pbuf_x_len), (u8_t *)tmp->payload , tmp->len ); - pbuf_x_len += tmp->len; - //cnt++; - tmp = tmp->next; + if (q->next == NULL) { + ret = esp_eth_tx(q->payload, q->len); + } else { + LWIP_DEBUGF(PBUF_DEBUG, ("low_level_output: pbuf is a list, application may has bug")); + q = pbuf_alloc(PBUF_RAW_TX, p->tot_len, PBUF_RAM); + if (q != NULL) { + q->l2_owner = NULL; + pbuf_copy(q, p); + } else { + return ERR_MEM; } + ret = esp_eth_tx(q->payload, q->len); + pbuf_free(q); } - return esp_eth_tx(q->payload, pbuf_x_len); -#else - for(q = p; q != NULL; q = q->next) { - return esp_emac_tx(q->payload, q->len); - } - return ERR_OK; -#endif + return ret; } /** @@ -152,10 +147,10 @@ ethernet_low_level_output(struct netif *netif, struct pbuf *p) * * @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 + * freeing the buffer. Otherwise, high layer and ethernet share the * same buffer and high layer is responsible for freeing the buffer. */ -void +void ESP_IRAM_ATTR ethernetif_input(struct netif *netif, void *buffer, uint16_t len) { struct pbuf *p;