netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org, vivien.didelot@gmail.com,
	davem@davemloft.net,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: Re: [PATCH net-next 1/2] net: dsa: Add ability to elect CPU port
Date: Tue, 29 Oct 2019 02:39:38 +0100	[thread overview]
Message-ID: <20191029013938.GG15259@lunn.ch> (raw)
In-Reply-To: <20191028223236.31642-2-f.fainelli@gmail.com>

On Mon, Oct 28, 2019 at 03:32:35PM -0700, Florian Fainelli wrote:
> In a configuration where multiple CPU ports are declared within the
> platform configuration, it may be desirable to make sure that a
> particular CPU port gets used. This is particularly true for Broadcom
> switch that are fairly flexible to some extent in which port can be the
> CPU port, yet will be more featureful if port 8 is elected.

> -static struct dsa_port *dsa_tree_find_first_cpu(struct dsa_switch_tree *dst)
> +static struct dsa_port *dsa_tree_find_cpu(struct dsa_switch_tree *dst)
>  {
> +	struct dsa_switch *ds;
>  	struct dsa_port *dp;
> +	int err;
>  
> -	list_for_each_entry(dp, &dst->ports, list)
> -		if (dsa_port_is_cpu(dp))
> +	list_for_each_entry(dp, &dst->ports, list) {
> +		ds = dp->ds;
> +		if (!dsa_port_is_cpu(dp))
> +			continue;
> +
> +		if (!ds->ops->elect_cpu_port)
>  			return dp;
>  
> +		err = ds->ops->elect_cpu_port(ds, dp->index);
> +		if (err == 0)
> +			return dp;
> +	}
> +
>  	return NULL;
>  }

Hi Florian

I think is_preferred_cpu_port() would be a better name, and maybe a
bool?

Also, i don't think we should be returning NULL at the end like
this. If the device tree does not have the preferred port as CPU port,
we should use dsa_tree_find_cpu() to pick one of the actually offered
CPU ports in DT? It sounds like your hardware will still work if any
port is used as the CPU port.

And maybe we need a is_valid_cpu_port()? Some of the chipsets only
have a subset which can be CPU ports, the hardware is not as flexible.
The core can then validate the CPU port really is valid, rather than
the driver, e.g. qca8k, validating the CPU port in setup() and
returning an error.

    Andrew

  reply	other threads:[~2019-10-29  1:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28 22:32 [PATCH net-next 0/2] net: dsa: Add ability to elect CPU port Florian Fainelli
2019-10-28 22:32 ` [PATCH net-next 1/2] " Florian Fainelli
2019-10-29  1:39   ` Andrew Lunn [this message]
2019-10-29 17:23     ` Florian Fainelli
2019-10-28 22:32 ` [PATCH net-next 2/2] net: dsa: b53: Add CPU port election callback Florian Fainelli
2019-10-30 21:44 ` [PATCH net-next 0/2] net: dsa: Add ability to elect CPU port David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191029013938.GG15259@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).