net: dsa: Add helper to resolve bridge port from DSA port
In order for a driver to be able to query a bridge for information
about itself, e.g. reading out port flags, it has to use a netdev that
is known to the bridge. In the simple case, that is just the netdev
representing the port, e.g. swp0 or swp1 in this example:
br0
/ \
swp0 swp1
But in the case of an offloaded lag, this will be the bond or team
interface, e.g. bond0 in this example:
br0
/
bond0
/ \
swp0 swp1
Add a helper that hides some of this complexity from the
drivers. Then, redefine dsa_port_offloads_bridge_port using the helper
to avoid double accounting of the set of possible offloaded uppers.
Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
44b958a686
commit
cc76ce9e8d
@@ -493,6 +493,20 @@ static inline bool dsa_port_is_vlan_filtering(const struct dsa_port *dp)
|
|||||||
return dp->vlan_filtering;
|
return dp->vlan_filtering;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
struct net_device *dsa_port_to_bridge_port(const struct dsa_port *dp)
|
||||||
|
{
|
||||||
|
if (!dp->bridge_dev)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (dp->lag_dev)
|
||||||
|
return dp->lag_dev;
|
||||||
|
else if (dp->hsr_dev)
|
||||||
|
return dp->hsr_dev;
|
||||||
|
|
||||||
|
return dp->slave;
|
||||||
|
}
|
||||||
|
|
||||||
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
|
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
|
||||||
bool is_static, void *data);
|
bool is_static, void *data);
|
||||||
struct dsa_switch_ops {
|
struct dsa_switch_ops {
|
||||||
|
|||||||
@@ -233,19 +233,7 @@ extern const struct phylink_mac_ops dsa_port_phylink_mac_ops;
|
|||||||
static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp,
|
static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp,
|
||||||
struct net_device *dev)
|
struct net_device *dev)
|
||||||
{
|
{
|
||||||
/* Switchdev offloading can be configured on: */
|
return dsa_port_to_bridge_port(dp) == dev;
|
||||||
|
|
||||||
if (dev == dp->slave)
|
|
||||||
/* DSA ports directly connected to a bridge, and event
|
|
||||||
* was emitted for the ports themselves.
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (dp->lag_dev == dev)
|
|
||||||
/* DSA ports connected to a bridge via a LAG */
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool dsa_port_offloads_bridge(struct dsa_port *dp,
|
static inline bool dsa_port_offloads_bridge(struct dsa_port *dp,
|
||||||
|
|||||||
Reference in New Issue
Block a user