• Vladimir Oltean's avatar
    net: dsa: export the dsa_port_is_{user,cpu,dsa} helpers · a8986681
    Vladimir Oltean authored
    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: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
    Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    a8986681
dsa.h 32.1 KB