* [PATCH net-next] net: dsa: assign default CPU port to all ports
@ 2017-06-15 19:06 Vivien Didelot
2017-06-15 19:14 ` Florian Fainelli
2017-06-15 21:23 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Vivien Didelot @ 2017-06-15 19:06 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Jason Cobham, Vivien Didelot
The current code only assigns the default cpu_dp to all user ports of
the switch to which the CPU port belongs. The user ports of the other
switches of the fabric thus don't have a default CPU port.
This patch fixes this by assigning the cpu_dp of all user ports of all
switches of the fabric when the tree is fully parsed.
Fixes: a29342e73911 ("net: dsa: Associate slave network device with CPU port")
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/dsa2.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 52af8401af07..56e46090526b 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -490,8 +490,6 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
enum dsa_tag_protocol tag_protocol;
struct net_device *ethernet_dev;
struct device_node *ethernet;
- struct dsa_port *p;
- unsigned int i;
if (port->dn) {
ethernet = of_parse_phandle(port->dn, "ethernet", 0);
@@ -509,15 +507,6 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
if (!dst->cpu_dp) {
dst->cpu_dp = port;
dst->cpu_dp->netdev = ethernet_dev;
-
- for (i = 0; i < ds->num_ports; i++) {
- p = &ds->ports[i];
- if (!dsa_port_is_valid(p) ||
- i == index)
- continue;
-
- p->cpu_dp = port;
- }
}
tag_protocol = ds->ops->get_tag_protocol(ds);
@@ -572,7 +561,9 @@ static int dsa_ds_parse(struct dsa_switch_tree *dst, struct dsa_switch *ds)
static int dsa_dst_parse(struct dsa_switch_tree *dst)
{
struct dsa_switch *ds;
+ struct dsa_port *dp;
u32 index;
+ int port;
int err;
for (index = 0; index < DSA_MAX_SWITCHES; index++) {
@@ -590,6 +581,23 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst)
return -EINVAL;
}
+ /* Assign the default CPU port to all ports of the fabric */
+ for (index = 0; index < DSA_MAX_SWITCHES; index++) {
+ ds = dst->ds[index];
+ if (!ds)
+ continue;
+
+ for (port = 0; port < ds->num_ports; port++) {
+ dp = &ds->ports[port];
+ if (!dsa_port_is_valid(dp) ||
+ dsa_port_is_dsa(dp) ||
+ dsa_port_is_cpu(dp))
+ continue;
+
+ dp->cpu_dp = dst->cpu_dp;
+ }
+ }
+
pr_info("DSA: tree %d parsed\n", dst->tree);
return 0;
--
2.13.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: dsa: assign default CPU port to all ports
2017-06-15 19:06 [PATCH net-next] net: dsa: assign default CPU port to all ports Vivien Didelot
@ 2017-06-15 19:14 ` Florian Fainelli
2017-06-15 21:23 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2017-06-15 19:14 UTC (permalink / raw)
To: Vivien Didelot, netdev
Cc: linux-kernel, kernel, David S. Miller, Andrew Lunn, Jason Cobham
On 06/15/2017 12:06 PM, Vivien Didelot wrote:
> The current code only assigns the default cpu_dp to all user ports of
> the switch to which the CPU port belongs. The user ports of the other
> switches of the fabric thus don't have a default CPU port.
Which would lead to a crash in dsa_master_netdev() :)
>
> This patch fixes this by assigning the cpu_dp of all user ports of all
> switches of the fabric when the tree is fully parsed.
>
> Fixes: a29342e73911 ("net: dsa: Associate slave network device with CPU port")
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Thanks for this fix:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: dsa: assign default CPU port to all ports
2017-06-15 19:06 [PATCH net-next] net: dsa: assign default CPU port to all ports Vivien Didelot
2017-06-15 19:14 ` Florian Fainelli
@ 2017-06-15 21:23 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-06-15 21:23 UTC (permalink / raw)
To: vivien.didelot; +Cc: netdev, linux-kernel, kernel, f.fainelli, andrew, jcobham
From: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Date: Thu, 15 Jun 2017 15:06:54 -0400
> The current code only assigns the default cpu_dp to all user ports of
> the switch to which the CPU port belongs. The user ports of the other
> switches of the fabric thus don't have a default CPU port.
>
> This patch fixes this by assigning the cpu_dp of all user ports of all
> switches of the fabric when the tree is fully parsed.
>
> Fixes: a29342e73911 ("net: dsa: Associate slave network device with CPU port")
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-15 21:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-15 19:06 [PATCH net-next] net: dsa: assign default CPU port to all ports Vivien Didelot
2017-06-15 19:14 ` Florian Fainelli
2017-06-15 21:23 ` David Miller
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).