Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1389644
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC 07/20] net: dsa: list ports in switch |
| Date | 2016-04-28 00:40 +0200 |
| Message-ID | <rsGhI-P8-15@gated-at.bofh.it> (permalink) |
| References | <rsGhH-P8-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
List DSA port structures in their switch structure, so that drivers can
iterate on them to retrieve information such as their ports membership.
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
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[RFC 07/20] net: dsa: list ports in switch Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-28 00:40 +0200
Re: [RFC 07/20] net: dsa: list ports in switch\\ Andrew Lunn <andrew@lunn.ch> - 2016-04-28 01:20 +0200
Re: [RFC 07/20] net: dsa: list ports in switch\\ Florian Fainelli <f.fainelli@gmail.com> - 2016-04-28 19:10 +0200
Re: [RFC 07/20] net: dsa: list ports in switch\\ Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2016-04-28 20:20 +0200
Re: [RFC 07/20] net: dsa: list ports in switch\\ Florian Fainelli <f.fainelli@gmail.com> - 2016-04-28 20:40 +0200
csiph-web