aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/dsa.h
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2021-12-06 18:57:55 +0200
committerJakub Kicinski <kuba@kernel.org>2021-12-08 14:31:16 -0800
commit6a43cba3034015d1c029c8a81b62eb9c2660fd6e (patch)
treec08e3479bd9cc1e44d748f79625d3eb37cfca214 /include/net/dsa.h
parentnet: dsa: rename dsa_port_offloads_bridge to dsa_port_offloads_bridge_dev (diff)
downloadlinux-dev-6a43cba3034015d1c029c8a81b62eb9c2660fd6e.tar.xz
linux-dev-6a43cba3034015d1c029c8a81b62eb9c2660fd6e.zip
net: dsa: export bridging offload helpers to drivers
Move the static inline helpers from net/dsa/dsa_priv.h to include/net/dsa.h, so that drivers can call functions such as dsa_port_offloads_bridge_dev(), which will be necessary after the transition to a more complex bridge structure. More functions than are needed right now are being moved, but this is done for uniformity. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/dsa.h')
-rw-r--r--include/net/dsa.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 18bce0383267..899e13d56fc2 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -620,6 +620,49 @@ static inline bool dsa_port_bridge_same(const struct dsa_port *a,
return (!br_a || !br_b) ? false : (br_a == br_b);
}
+static inline bool dsa_port_offloads_bridge_port(struct dsa_port *dp,
+ const struct net_device *dev)
+{
+ return dsa_port_to_bridge_port(dp) == dev;
+}
+
+static inline bool
+dsa_port_offloads_bridge_dev(struct dsa_port *dp,
+ const struct net_device *bridge_dev)
+{
+ /* DSA ports connected to a bridge, and event was emitted
+ * for the bridge.
+ */
+ return dsa_port_bridge_dev_get(dp) == bridge_dev;
+}
+
+/* Returns true if any port of this tree offloads the given net_device */
+static inline bool dsa_tree_offloads_bridge_port(struct dsa_switch_tree *dst,
+ const struct net_device *dev)
+{
+ struct dsa_port *dp;
+
+ list_for_each_entry(dp, &dst->ports, list)
+ if (dsa_port_offloads_bridge_port(dp, dev))
+ return true;
+
+ return false;
+}
+
+/* Returns true if any port of this tree offloads the given bridge */
+static inline bool
+dsa_tree_offloads_bridge_dev(struct dsa_switch_tree *dst,
+ const struct net_device *bridge_dev)
+{
+ struct dsa_port *dp;
+
+ list_for_each_entry(dp, &dst->ports, list)
+ if (dsa_port_offloads_bridge_dev(dp, bridge_dev))
+ return true;
+
+ return false;
+}
+
typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
bool is_static, void *data);
struct dsa_switch_ops {