diff options
author | Vivien Didelot <vivien.didelot@savoirfairelinux.com> | 2017-11-03 19:05:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-05 22:31:39 +0900 |
commit | 7354fcb0a3a3a5518107f8de117a6ce5ce08cc7c (patch) | |
tree | e595964139c83a0e7cabfb32ac8f85e1766f2bf9 | |
parent | 06e24d0868a361774fc46d0819450915e63a2815 (diff) |
net: dsa: resolve tagging protocol at parse time
Extend the dsa_port_parse_cpu() function to resolve the tagging protocol
at port parsing time, instead of waiting for the whole tree to be
complete.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/dsa/dsa2.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 271a97ef5bf6..283104e5ca6a 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -511,8 +511,23 @@ static int dsa_port_parse_dsa(struct dsa_port *dp) static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master) { + struct dsa_switch *ds = dp->ds; + struct dsa_switch_tree *dst = ds->dst; + const struct dsa_device_ops *tag_ops; + enum dsa_tag_protocol tag_protocol; + + tag_protocol = ds->ops->get_tag_protocol(ds); + tag_ops = dsa_resolve_tag_protocol(tag_protocol); + if (IS_ERR(tag_ops)) { + dev_warn(ds->dev, "No tagger for this switch\n"); + return PTR_ERR(tag_ops); + } + dp->type = DSA_PORT_TYPE_CPU; + dp->rcv = tag_ops->rcv; + dp->tag_ops = tag_ops; dp->master = master; + dp->dst = dst; return 0; } @@ -521,25 +536,9 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, struct dsa_switch_tree *dst, struct dsa_switch *ds) { - const struct dsa_device_ops *tag_ops; - enum dsa_tag_protocol tag_protocol; - if (!dst->cpu_dp) dst->cpu_dp = port; - tag_protocol = ds->ops->get_tag_protocol(ds); - tag_ops = dsa_resolve_tag_protocol(tag_protocol); - if (IS_ERR(tag_ops)) { - dev_warn(ds->dev, "No tagger for this switch\n"); - return PTR_ERR(tag_ops); - } - - dst->cpu_dp->tag_ops = tag_ops; - - /* Make a few copies for faster access in master receive hot path */ - dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv; - dst->cpu_dp->dst = dst; - return 0; } |