From: Andrew Lunn <andrew@lunn•ch>
To: Vivien Didelot <vivien.didelot@savoirfairelinux•com>
Cc: netdev@vger•kernel.org, linux-kernel@vger•kernel.org,
kernel@savoirfairelinux•com,
"David S. Miller" <davem@davemloft•net>,
Florian Fainelli <f.fainelli@gmail•com>,
Jiri Pirko <jiri@resnulli•us>
Subject: Re: [RFC 07/20] net: dsa: list ports in switch\\
Date: Thu, 28 Apr 2016 01:15:37 +0200 [thread overview]
Message-ID: <20160427231537.GJ29024@lunn.ch> (raw)
In-Reply-To: <1461796217-18893-8-git-send-email-vivien.didelot@savoirfairelinux.com>
On Wed, Apr 27, 2016 at 06:30:04PM -0400, Vivien Didelot wrote:
> List DSA port structures in their switch structure, so that drivers can
> iterate on them to retrieve information such as their ports membership.
And this would be so much easier using a plan array.
Andrew
>
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux•com>
> ---
> include/net/dsa.h | 9 +++++++++
> net/dsa/dsa.c | 4 ++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 69e467c..5f2e7df 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -32,6 +32,11 @@ enum dsa_tag_protocol {
> #define DSA_MAX_SWITCHES 4
> #define DSA_MAX_PORTS 12
>
> +#define dsa_switch_for_each_port(_ds, _dp, _num_ports) \
> + for (_dp = list_first_entry(&_ds->dp, typeof(*_dp), list); \
> + &_dp->list != (&_ds->dp) && _dp->port < _num_ports; \
> + _dp = list_next_entry(_dp, list))
> +
> struct dsa_chip_data {
> /*
> * How to access the switch configuration registers.
> @@ -123,6 +128,8 @@ struct dsa_switch_tree {
> };
>
> struct dsa_port {
> + struct list_head list;
> +
> struct dsa_switch *ds;
> int port;
>
> @@ -173,6 +180,8 @@ struct dsa_switch {
> u32 phys_mii_mask;
> struct mii_bus *slave_mii_bus;
> struct net_device *ports[DSA_MAX_PORTS];
> +
> + struct list_head dp;
> };
>
> static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 222494c..3daffb6 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -225,6 +225,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
> int index = ds->index;
> int i, ret;
>
> + INIT_LIST_HEAD(&ds->dp);
> +
> /*
> * Validate supplied switch configuration.
> */
> @@ -238,6 +240,8 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
> dp[i]->ds = ds;
> dp[i]->port = i;
>
> + list_add_tail(&dp[i]->list, &ds->dp);
> +
> name = pd->port_names[i];
> if (name == NULL)
> continue;
> --
> 2.8.0
>
next prev parent reply other threads:[~2016-04-27 23:15 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 22:29 [RFC 00/20] net: dsa: dsa_port structure and tree-wide ops Vivien Didelot
2016-04-27 22:29 ` [RFC 01/20] net: dsa: introduce a dsa_port structure Vivien Didelot
2016-04-27 23:07 ` Andrew Lunn
2016-04-27 22:29 ` [RFC 02/20] net: dsa: be consistent with NETDEV_CHANGEUPPER Vivien Didelot
2016-04-27 22:30 ` [RFC 03/20] net: dsa: pass dsa_port down to drivers bridge ops Vivien Didelot
2016-04-27 23:12 ` Andrew Lunn
2016-04-27 22:30 ` [RFC 04/20] net: dsa: pass dsa_port down to drivers FDB ops Vivien Didelot
2016-04-27 22:30 ` [RFC 05/20] net: dsa: pass dsa_port down to drivers VLAN ops Vivien Didelot
2016-04-27 22:30 ` [RFC 06/20] net: dsa: move bridge device in dsa_port Vivien Didelot
2016-04-27 22:30 ` [RFC 07/20] net: dsa: list ports in switch Vivien Didelot
2016-04-27 23:15 ` Andrew Lunn [this message]
2016-04-28 17:00 ` [RFC 07/20] net: dsa: list ports in switch\\ Florian Fainelli
2016-04-28 18:18 ` Vivien Didelot
2016-04-28 18:29 ` Florian Fainelli
2016-04-27 22:30 ` [RFC 08/20] net: dsa: bcm_sf2: use bridge device from dsa_port Vivien Didelot
2016-04-27 22:30 ` [RFC 09/20] net: dsa: mv88e6xxx: check HW vlan with dsa_port Vivien Didelot
2016-04-27 22:30 ` [RFC 10/20] net: dsa: mv88e6xxx: setup a dsa_port Vivien Didelot
2016-04-27 22:30 ` [RFC 11/20] net: dsa: mv88e6xxx: use bridge from dsa_port Vivien Didelot
2016-04-27 22:30 ` [RFC 12/20] net: dsa: rename dst->ds to dst->switches Vivien Didelot
2016-04-27 23:20 ` Andrew Lunn
2016-04-27 22:30 ` [RFC 13/20] net: dsa: list switches in tree Vivien Didelot
2016-04-27 22:30 ` [RFC 14/20] net: dsa: add tree-wide bridge ops Vivien Didelot
2016-04-27 22:30 ` [RFC 15/20] net: dsa: add tree-wide FDB ops Vivien Didelot
2016-04-27 22:30 ` [RFC 16/20] net: dsa: add tree-wide VLAN ops Vivien Didelot
2016-04-27 22:30 ` [RFC 17/20] net: dsa: mv88e6xxx: factorize port bridge change Vivien Didelot
2016-04-27 22:30 ` [RFC 18/20] net: dsa: mv88e6xxx: add flags to info Vivien Didelot
2016-04-27 22:30 ` [RFC 19/20] net: dsa: mv88e6xxx: conditionally init PVT Vivien Didelot
2016-04-27 22:30 ` [RFC 20/20] net: dsa: mv88e6xxx: setup PVT on cross-chip ops Vivien Didelot
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=20160427231537.GJ29024@lunn.ch \
--to=andrew@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=f.fainelli@gmail$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=kernel@savoirfairelinux$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=vivien.didelot@savoirfairelinux$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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