OSDN Git Service

net: dsa: export the dsa_port_is_{user,cpu,dsa} helpers
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 21 Jun 2021 16:42:15 +0000 (19:42 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jun 2021 19:50:20 +0000 (12:50 -0700)
commita8986681ccada614a30df7248390780e7708a763
tree8034667b4db5e55e09e1d935da7deb4856045c0d
parent8674f8d310215d2bb7469b80e6cfccc044f717b3
net: dsa: export the dsa_port_is_{user,cpu,dsa} helpers

The difference between dsa_is_user_port and dsa_port_is_user is that the
former needs to look up the list of ports of the DSA switch tree in
order to find the struct dsa_port, while the latter directly receives it
as an argument.

dsa_is_user_port is already in widespread use and has its place, so
there isn't any chance of converting all callers to a single form.
But being able to do:
dsa_port_is_user(dp)
instead of
dsa_is_user_port(dp->ds, dp->index)

is much more efficient too, especially when the "dp" comes from an
iterator over the DSA switch tree - this reduces the complexity from
quadratic to linear.

Move these helpers from dsa2.c to include/net/dsa.h so that others can
use them too.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dsa.h
net/dsa/dsa2.c