daniel-p-carvalho opened a new pull request, #20451:
URL: https://github.com/apache/nuttx/pull/20451

   ## Summary
   
   Fixes to the PIC32MZ Ethernet driver 
(`arch/mips/src/pic32mz/pic32mz_ethernet.c`),
   found while bringing up Ethernet on a PIC32MZ-W1 board (draft PR #20448).
   With the default configuration the driver stopped transmitting after two
   packets.
   
   * `arch/mips/pic32mz: fix the Ethernet driver TX ring, RX buffers and MAC.`
     * Close the TX descriptor ring on the last TX descriptor. The ring setup
       used `CONFIG_PIC32MZ_ETH_NRXDESC`, so with the defaults (2 TX, 4 RX
       descriptors) the last TX descriptor pointed past the TX ring and the TX
       DMA stopped after two packets.
     * Decrement `ETHSTAT.BUFCNT` (`ETHCON1.BUFCDEC`) for each received
       descriptor that is processed. The driver never decremented it.
     * Drop a received packet instead of hitting `DEBUGASSERT()` when no buffer
       is free to replace the one in the RX descriptor. With 7 buffers for 4 RX
       and 2 TX descriptors this happens under load.
     * Program `EMAC1SA0`-`EMAC1SA2` with the MAC address assigned to the device
       (e.g. `CONFIG_NETINIT_NOMAC` or `SIOCSIFHWADDR`), if any. The driver only
       read these registers. They are preloaded with a factory address on
       PIC32MZ EC/EF, so the behaviour there is unchanged when no address is
       assigned; on PIC32MZ-W1 they reset to zero.
   * `arch/mips/pic32mz: fix nxstyle issues in pic32mz_ethernet.c.`
     Pre-existing nxstyle errors (one indentation, one empty `while` body), so
     that the file passes checkpatch. No functional change.
   
   ## Impact
   
   * PIC32MZ Ethernet: transmission no longer stops after two packets, and the
     RX buffer count is maintained.
   * A MAC address assigned by the application or by NETINIT is now used by the
     hardware instead of being overwritten by the factory address.
   * No Kconfig, API or board changes.
   
   ## Testing
   
   * checkpatch: `./tools/checkpatch.sh -c -u -m -g upstream/master..HEAD`
     passes.
   * Build (Pinguino p32-gcc 4.9.2): `pic32mz-starterkit:nsh` with
     `CONFIG_NET`, `CONFIG_PIC32MZ_ETHERNET`, `CONFIG_ETH0_PHY_LAN8740`, TCP,
     UDP and ICMP enabled. No warnings.
   * Hardware: PIC32MZ-W1 (WFI32E01PE, B0 silicon) with a LAN8720A PHY (RMII,
     100 Mbps full duplex), using the W1 Ethernet support that will follow
     #20448, connected to a Linux host through a switch.
     * Before: ARP and the first ping reply went out, then nothing; the dumped
       TX descriptors showed `NEXTED` of the last one pointing past the ring.
     * After, ping from the host:
       ```
       $ ping -c 500 -i 0.005 -W 1 -q 192.168.100.2
       500 packets transmitted, 500 received, 0% packet loss, time 2494ms
       rtt min/avg/max/mdev = 0.692/0.788/0.975/0.067 ms
       $ ping -c 20 -i 0.05 -s 1400 -W 1 -q 192.168.100.2
       20 packets transmitted, 20 received, 0% packet loss, time 960ms
       rtt min/avg/max/mdev = 2.135/2.217/2.314/0.051 ms
       ```
       ping from the board to the host, and an NSH session over telnet, also
       work.
   * Not tested on PIC32MZ EC/EF hardware.
   


-- 
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]

Reply via email to