Re: [PATCH net-next 3/4] net: dsa: populate dp->link_dp for cascade ports

From: Simon Horman
Date: Sat Sep 14 2024 - 04:51:09 EST


On Fri, Sep 13, 2024 at 04:15:06PM +0300, Vladimir Oltean wrote:
> Drivers may need to walk the tree hop by hop, activity which is
> currently impossible. This is because dst->rtable offers no guarantee as
> to whether we are looking at a dsa_link that represents a direct
> connection or not.
>
> Partially address the long-standing TODO that we have, and do introduce
> a link_dp member in struct dsa_port. This will actually represent the
> adjacent cascade port.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@xxxxxxx>

...

> @@ -307,9 +308,23 @@ static struct dsa_link *dsa_link_touch(struct dsa_port *dp,
> INIT_LIST_HEAD(&dl->list);
> list_add_tail(&dl->list, &dst->rtable);
>
> + if (adjacent)
> + dp->link_dp = link_dp;
> +
> return dl;
> }
>
> +/**
> + * dsa_port_setup_routing_table(): Set up tree routing table based on
> + * information from this cascade port
> + * @dp: cascade port
> + *
> + * Parse the device tree node for the "link" array of phandles to other cascade
> + * ports, creating routing table elements from this source to each destination
> + * list element found. One assumption is being made, which is backed by the
> + * device tree bindings: that the first "link" element is the directly
> + * connected cascade port.
> + */

Hi Vladimir,

Another minor nit from my side (I think this is the last one).

Please consider documenting the return value of functions that return
a value using a "Return:" or "Returns:" section.

Flagged by ./scripts/kernel-doc -none -Wall

> static bool dsa_port_setup_routing_table(struct dsa_port *dp)
> {
> struct dsa_switch *ds = dp->ds;
> @@ -317,6 +332,7 @@ static bool dsa_port_setup_routing_table(struct dsa_port *dp)
> struct device_node *dn = dp->dn;
> struct of_phandle_iterator it;
> struct dsa_port *link_dp;
> + bool adjacent = true;
> struct dsa_link *dl;
> int err;
>

...