RE: [PATCH 2/2] net: ethernet: Add driver for Sunplus SP7021

From: Wells Lu 呂芳騰
Date: Tue Nov 09 2021 - 09:39:52 EST


> On Mon, Nov 08, 2021 at 04:47:34PM +0000, Wells Lu 呂芳騰 wrote:
> > > > The switch will not recognize type of packets, regardless BPDU,
> > > > PTP or any other packets. If turning off source-address learning
> > > > function, it works like an Ethernet plus a 2-port hub.
> > >
> > > So without STP, there is no way to stop an loop, and a broadcast
> > > storm taking down your network?
> >
> > Do you mean connecting two PHY ports to the same LAN? We never connect
> > two PHY ports to the same LAN (or hub). I never think of this loop
> > problem. I thought only WAN has the loop problem.
>
> Any Ethernet network can have a loop. Often loops a deliberate because they
> give redundancy. STP will detect this loop, and somewhere in the network one
> of the switches will block traffic to break the loop. But if something in the
> network breaks, the port can be unblocked to allow traffic to flow, redundancy.
> Well behaved switches should always implement STP.

I don't know how to implement STP in L2 switch like SP7021.
How about one NIC + 2-port simple frame-flooding hub?
Someone told me that some low-cost Ethernet hub just does frame-flooding
to other ports. Let users take care of use.
If this is acceptable, I'd like to have Ethernet of SP7021 have two operation
modes:
- Dual NIC mode
- Single NIC with 2-port frame-flooding hub mode

If this is not acceptable, can I, instead, implement the two operation modes:
- Dual NIC mode
- Single NIC mode

RMII pins of PHY ports of SP7021 are multiplexable. I'd like to switch RMII
pins of the second PHY for other use if single NIC mode is used.
In fact, some SP7021 boards have dual Ethernet and some have only one
Ethernet. We really need the two operation modes.


> > How an Ethernet hub take care of this situation?
>
> STP. Run tcpdump on your network. Depending on how your network is
> configured, you might see BPDU from your building switches.

Thanks a lot. I understand.

> > Is that reasonable to connect two ports of an Ethernet hub together?
>
> It is not just together. You cannot guarantee any Ethernet network is a tree. You
> could connect the two ports to two different hubs, but those hubs are
> connected together, and so you get a loop.

Thanks for explanation. I got it.

> > > Looking at the TX descriptor, there are two bits:
> > >
> > > [18]: force forward to port 0
> > > [19]: force forward to port 1
> > >
> > > When the switch is enabled, can these two bits be used?
> >
> > Yes, for example, when bit 19 of TX descriptor is enabled, a packet
> > from CPU port is forwarded to LAN port 0 forcibly.
> >
> >
> > > In the RX descriptor there is:
> > >
> > > pkt_sp:
> > > 000: from port0
> > > 001: from port1
> > > 110: soc0 loopback
> > > 101: soc1 loopback
> > >
> > > Are these bits used when the switch is enabled?
> >
> > Yes, E- MAC driver uses these bits to tell where a packet comes from.
> > Note that soc1 port (CPU port) has been removed in this chip.
>
> Right. So you can have two netdev when in L2 switch mode.
>
> You need to think about the Linux model some more. In linux, networking
> hardware is there to accelerate what the Linux stack can do in software. Take
> for example a simple SoC will have two Ethernet interfaces. You can perform
> software bridging on those two interfaces:
>
> ip link add name br0 type bridge
> ip link set dev br0 up
> ip link set dev eth0 master br0
> ip link set dev eth1 master br0
>
> The software bridge will decided which interface to send a packet out. The
> software will perform learning etc.
>
> You can use your dual MAC setup exactly like this. But you can also go further.
> You can use the hardware to accelerate switching packets between eth0 and
> eth1. But also Linux can still send packets out specific ports using these bits.
> The software bridge and the hardware bridge work together. This is the correct
> way to do this in Linux.

Sorry, I am not capable to do that.
I need to study more about Linux switch device, L2 switch of SP7021, procotols,...
So what I can use now is pure software bridge for dual Ethernet case.

> > Sorry, I don't know what is a RMC packet?
>
> Sorry, i have no idea.

After looking up some data, I find RMC means reserved multi-cast.
RMC packets means packets with DA = 0x0180c2000000, 0x0180c2000002 ~ 0x0180c200000f,
except the PAUSE packet (DA = 0x0180c2000001)


> Andrew

Thank you for your review.