tmedicci commented on code in PR #18827: URL: https://github.com/apache/nuttx/pull/18827#discussion_r3182651632
########## arch/risc-v/src/common/espressif/esp_emac.c: ########## @@ -0,0 +1,945 @@ +/**************************************************************************** + * arch/risc-v/src/common/espressif/esp_emac.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/config.h> + +#ifdef CONFIG_ESPRESSIF_EMAC + +#include <assert.h> +#include <debug.h> +#include <errno.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include <arpa/inet.h> +#include <net/if.h> + +#include <nuttx/arch.h> +#include <nuttx/irq.h> +#include <nuttx/kmalloc.h> +#include <nuttx/mutex.h> +#include <nuttx/queue.h> +#include <nuttx/spinlock.h> +#include <nuttx/wdog.h> +#include <nuttx/wqueue.h> +#include <nuttx/net/ioctl.h> +#include <nuttx/net/mii.h> +#include <nuttx/net/netdev.h> + +#ifdef CONFIG_NET_PKT +# include <nuttx/net/pkt.h> +#endif + +#include "esp_eth.h" +#include "esp_eth_driver.h" +#include "esp_eth_mac.h" +#include "esp_eth_mac_esp.h" +#include "esp_eth_phy.h" +#include "esp_event.h" +#include "esp_mac.h" + +#include "esp_emac.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define ETH_HEADER_LEN (14) +#define ETH_VLANTAG_LEN (4) +#define ETH_MAXPAYLOAD_LEN (1500) +#define ETH_CRC_LEN (4) + +#define ETH_MAXPKT_LEN (ETH_HEADER_LEN + ETH_VLANTAG_LEN + \ + ETH_MAXPAYLOAD_LEN + ETH_CRC_LEN) + +#define EMACWORK LPWORK + +#define EMAC_PHY_ADDR (CONFIG_ESPRESSIF_ETH_PHY_ADDR) + +#define NET2PRIV(_dev) ((struct esp_emac_s *)(_dev)->d_private) + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct esp_emac_rxpkt_s +{ + sq_entry_t entry; + uint8_t *buf; /* Buffer allocated by esp_eth; we must free() it */ + uint32_t len; +}; + +struct esp_emac_s +{ + struct net_driver_s dev; Review Comment: Hi @xiaoxiang781216 , I'm not sure if I got this, but I changed the `esp_emac.c` to use `struct netdev_lowerhalf_s` interface. In fact, I was able to get rid of a lot of code. I pushed it without rebasing to ease comparison: https://github.com/apache/nuttx/compare/09cdbe1bfc045809f5af0893a427e7710c84e902..47fd70eb18056d8be7274390f74b792279561326 Can you please take a look? (I'm going to rebase in a different push). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
