mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_eth: allowed DM9051 to receive multicast packets
Removed extra PHY status link checks from DM9051 MAC layer
This commit is contained in:
parent
8cea38360f
commit
fc09ea7b19
@ -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
|
||||
|
||||
@ -108,7 +100,7 @@ extern "C" {
|
||||
#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_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
|
||||
|
@ -286,9 +286,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 */
|
||||
@ -514,16 +514,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:
|
||||
@ -538,16 +533,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:
|
||||
@ -562,17 +552,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");
|
||||
@ -588,7 +573,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 {
|
||||
|
Loading…
Reference in New Issue
Block a user