daniel-p-carvalho opened a new pull request, #20517:
URL: https://github.com/apache/nuttx/pull/20517
## Summary
Add `CONFIG_NET_PROMISCUOUS` support to the PIC32MZ Ethernet driver
(`arch/mips/src/pic32mz/pic32mz_ethernet.c`). The option is documented as
"Force the Ethernet driver to operate in promiscuous mode (if supported by
the Ethernet driver)" and is already implemented by other drivers (stm32h7,
sam_emac, imx9, ...), but the PIC32MZ driver ignored it: the receive filter
only accepted broadcast frames, unicast frames sent to the station address
and, with `CONFIG_PIC32MZ_MULTICAST`, multicast frames.
With `CONFIG_NET_PROMISCUOUS`, `pic32mz_ifup()` now also enables the
multicast (`MCEN`) and "not me" unicast (`NOTMEEN`) filters of `ETHRXFC`,
so the MAC accepts every frame on the link (register description: PIC32MZ
W1 data sheet DS70005425, Register 33-11 ETHRXFC; same register on
PIC32MZ EC/EF).
The motivation is an Ethernet to Wi-Fi bridge on a PIC32MZ-W1 board (PR
#20448), where the Ethernet side must receive frames addressed to the MAC
addresses of the stations behind the bridge.
## Impact
* Only when `CONFIG_NET_PROMISCUOUS=y` (default n). Without it the
`ETHRXFC` value is unchanged.
* No change to other drivers, the build or the documentation.
## Testing
Host: Ubuntu Linux x86_64, USB Ethernet adapter connected directly to the
board.
**Hardware:** Microchip EV49N51A (PIC32MZ-W1, LAN8720A), XC32 v6.00, using
the board support of #20448 plus the W1 Ethernet support (not yet
upstream) with this commit cherry-picked, `netnsh` configuration with
`CONFIG_NET_STATISTICS=y`. Board 192.168.100.2, host 192.168.100.1.
On the host, a static neighbour entry for an address that does not exist,
so the host sends unicast frames to a MAC that is not the board's:
```
$ sudo ip neigh replace 192.168.100.99 lladdr 02:11:22:33:44:55 \
dev enx18dbf2154380 nud permanent
$ ping -c 20 -i 0.2 192.168.100.99
```
The host transmit counter went up by 20 in both runs. Board `ifconfig`
counters (hexadecimal) before and after the ping:
| Configuration | IPv4 Received | IPv4 Dropped |
|---|---|---|
| `CONFIG_NET_PROMISCUOUS=y` | 0x15 -> 0x40 (+43, 20 of them from a ping to
the board in between) | 0x15 -> 0x2c (+23) |
| `CONFIG_NET_PROMISCUOUS` not set | 0x14 -> 0x14 (+0) | 0x0 -> 0x0 (+0) |
With the option, the frames for the foreign MAC reach the stack and are
dropped by the IPv4 layer (destination address is not the board's);
without it the MAC filters them out. In both configurations
`ping -c 20 192.168.100.2` from the host: 0% loss, about 0.63 ms.
**Build:** `pic32mz-starterkit:nsh` (PIC32MZ EC) with `CONFIG_NET`,
`CONFIG_PIC32MZ_ETHERNET`, `CONFIG_ETH0_PHY_LAN8740A`, work queues and
`CONFIG_NET_PROMISCUOUS=y`, Pinguino p32-gcc 4.9.2: builds without
warnings.
`./tools/checkpatch.sh -c -u -m -g upstream/master..HEAD`: all checks pass.
--
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]