Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IPv6 Eth MAC KSZ8851SNL IDF 4.4 (IDFGH-12400) #13426

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions components/esp_eth/src/esp_eth_mac_ksz8851snl.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ static esp_err_t init_set_defaults(emac_ksz8851snl_t *emac)
ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_ISR, ISR_ALL), err, TAG, "ISR write failed");
ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_IER, IER_TXIE | IER_RXIE | IER_LDIE | IER_SPIBEIE | IER_RXOIE), err, TAG, "IER write failed");
ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_TXQCR, TXQCR_AETFE), err, TAG, "TXQCR write failed");
#ifdef CONFIG_LWIP_IPV6
ESP_GOTO_ON_ERROR(ksz8851_clear_bits(emac, KSZ8851_RXCR1, RXCR1_RXINVF), err, TAG, "RXCR1 write failed");
ESP_GOTO_ON_ERROR(ksz8851_set_bits(emac, KSZ8851_RXCR1, RXCR1_RXAE | RXCR1_RXPAFMA | RXCR1_RXMAFMA), err, TAG, "RXCR1 write failed");
ESP_LOGD(TAG, "enabled multi-cast RX");
#endif
return ESP_OK;
err:
return ret;
Expand Down Expand Up @@ -601,10 +606,16 @@ static esp_err_t emac_ksz8851_set_promiscuous(esp_eth_mac_t *mac, bool enable)
rxcr1 |= RXCR1_RXINVF | RXCR1_RXAE;
rxcr1 &= ~(RXCR1_RXPAFMA | RXCR1_RXMAFMA);
} else {
#ifdef CONFIG_LWIP_IPV6
ESP_LOGD(TAG, "setting perfect with multi-cast address passed mode");
rxcr1 |= RXCR1_RXAE | RXCR1_RXPAFMA | RXCR1_RXMAFMA;
rxcr1 &= ~(RXCR1_RXINVF);
#else
// NOTE(v.chistyakov): set hash perfect (default)
ESP_LOGD(TAG, "setting hash perfect mode");
rxcr1 |= RXCR1_RXPAFMA;
rxcr1 &= ~(RXCR1_RXINVF | RXCR1_RXAE | RXCR1_RXMAFMA);
#endif
}
ESP_GOTO_ON_ERROR(ksz8851_write_reg(emac, KSZ8851_RXCR1, rxcr1), err, TAG, "RXCR1 write failed");
err:
Expand Down
18 changes: 18 additions & 0 deletions examples/ethernet/basic/main/ethernet_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
ESP_LOGI(TAG, "~~~~~~~~~~~");
#ifdef CONFIG_LWIP_IPV6
esp_netif_t *netif = event->esp_netif;
esp_netif_create_ip6_linklocal(netif);
#endif
}

/** Event handler for IP_EVENT_GOT_IP6 */
static void got_ip6_event_handler(void *arg, esp_event_base_t event_base,
int32_t event_id, void *event_data)
{
ip_event_got_ip6_t *event = (ip_event_got_ip6_t *) event_data;
const esp_netif_ip6_info_t *ip6_info = &event->ip6_info;

ESP_LOGI(TAG, "Ethernet Got IPv6 Address");
ESP_LOGI(TAG, "~~~~~~~~~~~");
ESP_LOGI(TAG, "ETHIP:" IPV6STR, IPV62STR(ip6_info->ip));
ESP_LOGI(TAG, "~~~~~~~~~~~");
}

void app_main(void)
Expand Down Expand Up @@ -268,6 +285,7 @@ void app_main(void)
// Register user defined event handers
ESP_ERROR_CHECK(esp_event_handler_register(ETH_EVENT, ESP_EVENT_ANY_ID, &eth_event_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, &got_ip_event_handler, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_GOT_IP6, &got_ip6_event_handler, NULL));

/* start Ethernet driver state machine */
#if CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET
Expand Down