Re: [PATCH RFC net-next 1/3] net: dsa: allow for multiple CPU ports

From: Ansuel Smith
Date: Mon Apr 12 2021 - 06:20:21 EST


On Mon, Apr 12, 2021 at 11:35:25AM +0800, DENG Qingfang wrote:
> On Sat, Apr 10, 2021 at 03:34:47PM +0200, Ansuel Smith wrote:
> > Allow for multiple CPU ports in a DSA switch tree. By default the first
> > CPU port is assigned mimic the original assignement logic. A DSA driver
> > can define a function to declare a preferred CPU port based on the
> > provided port. If the function doesn't have a preferred port the CPU
> > port is assigned using a round-robin way starting from the last assigned
> > CPU port.
> > Examples:
> > There are two CPU port but no port_get_preferred_cpu is provided:
> > - The old logic is used. Every port is assigned to the first cpu port.
> > There are two CPU port but the port_get_preferred_cpu return -1:
> > - The port is assigned using a round-robin way since no preference is
> > provided.
> > There are two CPU port and the port_get_preferred_cpu define only one
> > port and the rest with -1: (wan port with CPU1 and the rest no
> > preference)
> > lan1 <-> eth0
> > lan2 <-> eth1
> > lan3 <-> eth0
> > lan4 <-> eth1
> > wan <-> eth1
> > There are two CPU port and the port_get_preferred assign a preference
> > for every port: (wan port with CPU1 everything else CPU0)
> > lan1 <-> eth0
> > lan2 <-> eth0
> > lan3 <-> eth0
> > lan4 <-> eth0
> > wan <-> eth1
>
> So, drivers will read the name of every port and decide which CPU port
> does it use?
>

Yes, this seems to be an acceptable path to follow. The driver can
provide a preferred CPU port or just tell DSA that every cpu is equal
and assign them in a round-robin.

> >
> > Signed-off-by: Marek Beh?n <marek.behun@xxxxxx>
> > Signed-off-by: Ansuel Smith <ansuelsmth@xxxxxxxxx>