diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-06-15 15:06:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-15 17:23:35 -0400 |
commit | e4b7778769c25f773c514dcc99afcf7c74a9b3e4 (patch) | |
tree | ef5cc0006c329b562f16f026b856b3c701ce5c06 /net/dsa/dsa2.c | |
parent | 3715c47bcda8bb56f7e2be27276282a2d0d48c09 (diff) |
net: dsa: assign default CPU port to all ports
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>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa2.c')
-rw-r--r-- | net/dsa/dsa2.c | 30 |
1 files 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, | |||
490 | enum dsa_tag_protocol tag_protocol; | 490 | enum dsa_tag_protocol tag_protocol; |
491 | struct net_device *ethernet_dev; | 491 | struct net_device *ethernet_dev; |
492 | struct device_node *ethernet; | 492 | struct device_node *ethernet; |
493 | struct dsa_port *p; | ||
494 | unsigned int i; | ||
495 | 493 | ||
496 | if (port->dn) { | 494 | if (port->dn) { |
497 | ethernet = of_parse_phandle(port->dn, "ethernet", 0); | 495 | ethernet = of_parse_phandle(port->dn, "ethernet", 0); |
@@ -509,15 +507,6 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, | |||
509 | if (!dst->cpu_dp) { | 507 | if (!dst->cpu_dp) { |
510 | dst->cpu_dp = port; | 508 | dst->cpu_dp = port; |
511 | dst->cpu_dp->netdev = ethernet_dev; | 509 | dst->cpu_dp->netdev = ethernet_dev; |
512 | |||
513 | for (i = 0; i < ds->num_ports; i++) { | ||
514 | p = &ds->ports[i]; | ||
515 | if (!dsa_port_is_valid(p) || | ||
516 | i == index) | ||
517 | continue; | ||
518 | |||
519 | p->cpu_dp = port; | ||
520 | } | ||
521 | } | 510 | } |
522 | 511 | ||
523 | tag_protocol = ds->ops->get_tag_protocol(ds); | 512 | 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) | |||
572 | static int dsa_dst_parse(struct dsa_switch_tree *dst) | 561 | static int dsa_dst_parse(struct dsa_switch_tree *dst) |
573 | { | 562 | { |
574 | struct dsa_switch *ds; | 563 | struct dsa_switch *ds; |
564 | struct dsa_port *dp; | ||
575 | u32 index; | 565 | u32 index; |
566 | int port; | ||
576 | int err; | 567 | int err; |
577 | 568 | ||
578 | for (index = 0; index < DSA_MAX_SWITCHES; index++) { | 569 | for (index = 0; index < DSA_MAX_SWITCHES; index++) { |
@@ -590,6 +581,23 @@ static int dsa_dst_parse(struct dsa_switch_tree *dst) | |||
590 | return -EINVAL; | 581 | return -EINVAL; |
591 | } | 582 | } |
592 | 583 | ||
584 | /* Assign the default CPU port to all ports of the fabric */ | ||
585 | for (index = 0; index < DSA_MAX_SWITCHES; index++) { | ||
586 | ds = dst->ds[index]; | ||
587 | if (!ds) | ||
588 | continue; | ||
589 | |||
590 | for (port = 0; port < ds->num_ports; port++) { | ||
591 | dp = &ds->ports[port]; | ||
592 | if (!dsa_port_is_valid(dp) || | ||
593 | dsa_port_is_dsa(dp) || | ||
594 | dsa_port_is_cpu(dp)) | ||
595 | continue; | ||
596 | |||
597 | dp->cpu_dp = dst->cpu_dp; | ||
598 | } | ||
599 | } | ||
600 | |||
593 | pr_info("DSA: tree %d parsed\n", dst->tree); | 601 | pr_info("DSA: tree %d parsed\n", dst->tree); |
594 | 602 | ||
595 | return 0; | 603 | return 0; |