Skip to content

Commit 7354fcb

Browse files
viviendavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06e24d0 commit 7354fcb

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

net/dsa/dsa2.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,23 @@ static int dsa_port_parse_dsa(struct dsa_port *dp)
511511

512512
static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master)
513513
{
514+
struct dsa_switch *ds = dp->ds;
515+
struct dsa_switch_tree *dst = ds->dst;
516+
const struct dsa_device_ops *tag_ops;
517+
enum dsa_tag_protocol tag_protocol;
518+
519+
tag_protocol = ds->ops->get_tag_protocol(ds);
520+
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
521+
if (IS_ERR(tag_ops)) {
522+
dev_warn(ds->dev, "No tagger for this switch\n");
523+
return PTR_ERR(tag_ops);
524+
}
525+
514526
dp->type = DSA_PORT_TYPE_CPU;
527+
dp->rcv = tag_ops->rcv;
528+
dp->tag_ops = tag_ops;
515529
dp->master = master;
530+
dp->dst = dst;
516531

517532
return 0;
518533
}
@@ -521,25 +536,9 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
521536
struct dsa_switch_tree *dst,
522537
struct dsa_switch *ds)
523538
{
524-
const struct dsa_device_ops *tag_ops;
525-
enum dsa_tag_protocol tag_protocol;
526-
527539
if (!dst->cpu_dp)
528540
dst->cpu_dp = port;
529541

530-
tag_protocol = ds->ops->get_tag_protocol(ds);
531-
tag_ops = dsa_resolve_tag_protocol(tag_protocol);
532-
if (IS_ERR(tag_ops)) {
533-
dev_warn(ds->dev, "No tagger for this switch\n");
534-
return PTR_ERR(tag_ops);
535-
}
536-
537-
dst->cpu_dp->tag_ops = tag_ops;
538-
539-
/* Make a few copies for faster access in master receive hot path */
540-
dst->cpu_dp->rcv = dst->cpu_dp->tag_ops->rcv;
541-
dst->cpu_dp->dst = dst;
542-
543542
return 0;
544543
}
545544

0 commit comments

Comments
 (0)