[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220107150056.250437-8-vladimir.oltean@nxp.com>
Date: Fri, 7 Jan 2022 17:00:51 +0200
From: Vladimir Oltean <vladimir.oltean@....com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew@...n.ch>,
Vivien Didelot <vivien.didelot@...il.com>,
Florian Fainelli <f.fainelli@...il.com>,
Ansuel Smith <ansuelsmth@...il.com>,
Tobias Waldekranz <tobias@...dekranz.com>,
DENG Qingfang <dqfext@...il.com>
Subject: [RFC PATCH net-next 07/12] net: switchdev: export switchdev_lower_dev_find
This little function that retrieves the first lower interface of @dev
that passes the @check_cb and @foreign_dev_check_cb criteria is useful
outside of the switchdev core, too. For example, drivers may use it to
retrieve a pointer to one of their own netdevices beneath a LAG.
Export it for driver use, to reduce code duplication.
Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
---
include/net/switchdev.h | 6 ++++++
net/switchdev/switchdev.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index d353793dfeb5..40b348f9898c 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -299,6 +299,12 @@ void switchdev_port_fwd_mark_set(struct net_device *dev,
struct net_device *group_dev,
bool joining);
+struct net_device *
+switchdev_lower_dev_find(struct net_device *dev,
+ bool (*check_cb)(const struct net_device *dev),
+ bool (*foreign_dev_check_cb)(const struct net_device *dev,
+ const struct net_device *foreign_dev));
+
int switchdev_handle_fdb_event_to_device(struct net_device *dev, unsigned long event,
const struct switchdev_notifier_fdb_info *fdb_info,
bool (*check_cb)(const struct net_device *dev),
diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index b62565278fac..85a84fe6eff3 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -408,7 +408,7 @@ static int switchdev_lower_dev_walk(struct net_device *lower_dev,
return 0;
}
-static struct net_device *
+struct net_device *
switchdev_lower_dev_find(struct net_device *dev,
bool (*check_cb)(const struct net_device *dev),
bool (*foreign_dev_check_cb)(const struct net_device *dev,
@@ -428,6 +428,7 @@ switchdev_lower_dev_find(struct net_device *dev,
return switchdev_priv.lower_dev;
}
+EXPORT_SYMBOL_GPL(switchdev_lower_dev_find);
static int __switchdev_handle_fdb_event_to_device(struct net_device *dev,
struct net_device *orig_dev, unsigned long event,
--
2.25.1
Powered by blists - more mailing lists