mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
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>
This commit is contained in:
parent
8674f8d310
commit
a8986681cc
2 changed files with 15 additions and 15 deletions
|
@ -409,6 +409,21 @@ static inline struct dsa_port *dsa_to_port(struct dsa_switch *ds, int p)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static inline bool dsa_port_is_dsa(struct dsa_port *port)
|
||||
{
|
||||
return port->type == DSA_PORT_TYPE_DSA;
|
||||
}
|
||||
|
||||
static inline bool dsa_port_is_cpu(struct dsa_port *port)
|
||||
{
|
||||
return port->type == DSA_PORT_TYPE_CPU;
|
||||
}
|
||||
|
||||
static inline bool dsa_port_is_user(struct dsa_port *dp)
|
||||
{
|
||||
return dp->type == DSA_PORT_TYPE_USER;
|
||||
}
|
||||
|
||||
static inline bool dsa_is_unused_port(struct dsa_switch *ds, int p)
|
||||
{
|
||||
return dsa_to_port(ds, p)->type == DSA_PORT_TYPE_UNUSED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue