diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2021-10-20 20:49:49 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-10-21 14:44:06 +0300 |
commit | 82b318983c515f29b8b3a0dad9f6a5fe8a68a7f4 (patch) | |
tree | 99a6f20606286bc490afa67225236f6c049d3dd0 /net/dsa/switch.c | |
parent | dedb0809c9ba8a1ab64901e1f7aac267d3395fa8 (diff) | |
download | linux-82b318983c515f29b8b3a0dad9f6a5fe8a68a7f4.tar.xz |
net: dsa: introduce helpers for iterating through ports using dp
Since the DSA conversion from the ds->ports array into the dst->ports
list, the DSA API has encouraged driver writers, as well as the core
itself, to write inefficient code.
Currently, code that wants to filter by a specific type of port when
iterating, like {!unused, user, cpu, dsa}, uses the dsa_is_*_port helper.
Under the hood, this uses dsa_to_port which iterates again through
dst->ports. But the driver iterates through the port list already, so
the complexity is quadratic for the typical case of a single-switch
tree.
This patch introduces some iteration helpers where the iterator is
already a struct dsa_port *dp, so that the other variant of the
filtering functions, dsa_port_is_{unused,user,cpu_dsa}, can be used
directly on the iterator. This eliminates the second lookup.
These functions can be used both by the core and by drivers.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/switch.c')
0 files changed, 0 insertions, 0 deletions