diff --git a/components/esp_eth/src/dm9051.h b/components/esp_eth/src/dm9051.h index acc855dec3..a1fa85c69c 100644 --- a/components/esp_eth/src/dm9051.h +++ b/components/esp_eth/src/dm9051.h @@ -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-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -105,13 +97,13 @@ extern "C" { #define TCR_TXREQ (1 << 0) // TX Request. Auto-Clear after Sending Completely -#define RCR_WTDIS (1 << 6) // Watchdog Timer Disable -#define RCR_DIS_LONG (1 << 5) // Discard Long Packet -#define RCR_DIS_CRC (1 << 4) // Discard CRC Error Packet -#define RCR_ALL (1 << 3) // Receive All Multicast -#define RCR_RUNT (1 << 2) // Receive Runt Packet -#define RCR_PRMSC (1 << 1) // Promiscuous Mode -#define RCR_RXEN (1 << 0) // RX Enable +#define RCR_WTDIS (1 << 6) // Watchdog Timer Disable +#define RCR_DIS_LONG (1 << 5) // Discard Long Packet +#define RCR_DIS_CRC (1 << 4) // Discard CRC Error Packet +#define RCR_ALL_MCAST (1 << 3) // Receive All Multicast +#define RCR_RUNT (1 << 2) // Receive Runt Packet +#define RCR_PRMSC (1 << 1) // Promiscuous Mode +#define RCR_RXEN (1 << 0) // RX Enable #define RSR_RF (1 << 7) // Runt Frame #define RSR_MF (1 << 6) // Multicast Frame diff --git a/components/esp_eth/src/esp_eth_mac_dm9051.c b/components/esp_eth/src/esp_eth_mac_dm9051.c index a2da223107..b0d339cc93 100644 --- a/components/esp_eth/src/esp_eth_mac_dm9051.c +++ b/components/esp_eth/src/esp_eth_mac_dm9051.c @@ -296,9 +296,9 @@ static esp_err_t dm9051_setup_default(emac_dm9051_t *emac) ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_WCR, 0x00), err, TAG, "write WCR failed"); /* stop transmitting, enable appending pad, crc for packets */ ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_TCR, 0x00), err, TAG, "write TCR failed"); - /* stop receiving, no promiscuous mode, no runt packet(size < 64bytes), not all multicast packets*/ + /* stop receiving, no promiscuous mode, no runt packet(size < 64bytes), receive all multicast packets */ /* discard long packet(size > 1522bytes) and crc error packet, enable watchdog */ - ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_RCR, RCR_DIS_LONG | RCR_DIS_CRC), err, TAG, "write RCR failed"); + ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_RCR, RCR_DIS_LONG | RCR_DIS_CRC | RCR_ALL_MCAST), err, TAG, "write RCR failed"); /* retry late collision packet, at most two transmit command can be issued before transmit complete */ ESP_GOTO_ON_ERROR(dm9051_register_write(emac, DM9051_TCR2, TCR2_RLCP), err, TAG, "write TCR2 failed"); /* enable auto transmit */ @@ -486,16 +486,11 @@ err: static esp_err_t emac_dm9051_set_link(esp_eth_mac_t *mac, eth_link_t link) { esp_err_t ret = ESP_OK; - emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); - uint8_t nsr = 0; - ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_NSR, &nsr), err, TAG, "read NSR failed"); switch (link) { case ETH_LINK_UP: - ESP_GOTO_ON_FALSE(nsr & NSR_LINKST, ESP_ERR_INVALID_STATE, err, TAG, "phy is not link up"); ESP_GOTO_ON_ERROR(mac->start(mac), err, TAG, "dm9051 start failed"); break; case ETH_LINK_DOWN: - ESP_GOTO_ON_FALSE(!(nsr & NSR_LINKST), ESP_ERR_INVALID_STATE, err, TAG, "phy is not link down"); ESP_GOTO_ON_ERROR(mac->stop(mac), err, TAG, "dm9051 stop failed"); break; default: @@ -510,16 +505,11 @@ err: static esp_err_t emac_dm9051_set_speed(esp_eth_mac_t *mac, eth_speed_t speed) { esp_err_t ret = ESP_OK; - emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); - uint8_t nsr = 0; - ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_NSR, &nsr), err, TAG, "read NSR failed"); switch (speed) { case ETH_SPEED_10M: - ESP_GOTO_ON_FALSE(nsr & NSR_SPEED, ESP_ERR_INVALID_STATE, err, TAG, "phy speed is not at 10Mbps"); ESP_LOGD(TAG, "working in 10Mbps"); break; case ETH_SPEED_100M: - ESP_GOTO_ON_FALSE(!(nsr & NSR_SPEED), ESP_ERR_INVALID_STATE, err, TAG, "phy speed is not at 100Mbps"); ESP_LOGD(TAG, "working in 100Mbps"); break; default: @@ -534,17 +524,12 @@ err: static esp_err_t emac_dm9051_set_duplex(esp_eth_mac_t *mac, eth_duplex_t duplex) { esp_err_t ret = ESP_OK; - emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); - uint8_t ncr = 0; - ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_NCR, &ncr), err, TAG, "read NCR failed"); switch (duplex) { case ETH_DUPLEX_HALF: ESP_LOGD(TAG, "working in half duplex"); - ESP_GOTO_ON_FALSE(!(ncr & NCR_FDX), ESP_ERR_INVALID_STATE, err, TAG, "phy is not at half duplex"); break; case ETH_DUPLEX_FULL: ESP_LOGD(TAG, "working in full duplex"); - ESP_GOTO_ON_FALSE(ncr & NCR_FDX, ESP_ERR_INVALID_STATE, err, TAG, "phy is not at full duplex"); break; default: ESP_GOTO_ON_FALSE(false, ESP_ERR_INVALID_ARG, err, TAG, "unknown duplex"); @@ -560,7 +545,7 @@ static esp_err_t emac_dm9051_set_promiscuous(esp_eth_mac_t *mac, bool enable) esp_err_t ret = ESP_OK; emac_dm9051_t *emac = __containerof(mac, emac_dm9051_t, parent); uint8_t rcr = 0; - ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_EPDRL, &rcr), err, TAG, "read RCR failed"); + ESP_GOTO_ON_ERROR(dm9051_register_read(emac, DM9051_RCR, &rcr), err, TAG, "read RCR failed"); if (enable) { rcr |= RCR_PRMSC; } else { diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 06a3c78985..ac1e315cd6 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -398,7 +398,6 @@ components/bt/host/bluedroid/stack/smp/smp_main.c components/bt/host/bluedroid/stack/smp/smp_utils.c components/console/linenoise/linenoise.c components/console/linenoise/linenoise.h -components/esp_eth/src/dm9051.h components/esp_eth/src/ksz8851.h components/esp_eth/test_apps/component_ut_test.py components/esp_eth/test_apps/main/esp_eth_test.c