summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-02-26 08:49:06 -0800
committerDavid S. Miller <davem@davemloft.net>2019-02-26 08:49:06 -0800
commit703bdcbc8e4e19ab4e1a5d819251978b85777f53 (patch)
tree8b81f90a9de84f1842cf21285ff8a417497a2075 /include/net
parentd8cf757fbd3ee96a449f656707e773c91ca805b8 (diff)
parentbe6fe1d8e1023bd80e122fa5eeeaff2ce66e9247 (diff)
downloadlinux-703bdcbc8e4e19ab4e1a5d819251978b85777f53.tar.bz2
Merge branch 'devlink-make-ethtool-compat-reliable'
Jakub Kicinski says: ==================== devlink: make ethtool compat reliable This is a follow up to the series which added device flash updates via devlink. I went with the approach of adding a new NDO in the end. It seems to end up looking cleaner. First patch removes the option to build devlink as a module. Users can still decide to not build it, but the module option ends up not being worth the maintenance cost. Next two patches add a NDO which can be used to ask the driver to return a devlink instance associated with a given netdev, instead of iterating over devlink ports. Drivers which implement this NDO must take into account the potential impact on the visibility of the devlink instance. With the new NDO in place we can remove NFP ethtool flash update code. Fifth patch makes sure we hold a reference to dev while callbacks are active. Last but not least the NULL-check of devlink->ops is moved to instance allocation time. Last but not least missing checks for devlink->ops are added. There is currently no driver registering devlink without ops, so can just fix this in -next. v2 (Michal): add netdev_to_devlink() in patch 3. v3 (Florian): - add missing checks for devlink->ops; - move locking/holding into devlink_compat_ functions. v4 (Jiri): - hold devlink_mutex around callbacks (patch 2); - require non-NULL ops (patch 6). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/devlink.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/include/net/devlink.h b/include/net/devlink.h
index a2da49dd9147..7f5a0bdca228 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -538,6 +538,15 @@ static inline struct devlink *priv_to_devlink(void *priv)
return container_of(priv, struct devlink, priv);
}
+static inline struct devlink *netdev_to_devlink(struct net_device *dev)
+{
+#if IS_ENABLED(CONFIG_NET_DEVLINK)
+ if (dev->netdev_ops->ndo_get_devlink)
+ return dev->netdev_ops->ndo_get_devlink(dev);
+#endif
+ return NULL;
+}
+
struct ib_device;
#if IS_ENABLED(CONFIG_NET_DEVLINK)
@@ -707,6 +716,10 @@ devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
int devlink_health_report(struct devlink_health_reporter *reporter,
const char *msg, void *priv_ctx);
+void devlink_compat_running_version(struct net_device *dev,
+ char *buf, size_t len);
+int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
+
#else
static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
@@ -1190,13 +1203,7 @@ devlink_health_report(struct devlink_health_reporter *reporter,
{
return 0;
}
-#endif
-#if IS_REACHABLE(CONFIG_NET_DEVLINK)
-void devlink_compat_running_version(struct net_device *dev,
- char *buf, size_t len);
-int devlink_compat_flash_update(struct net_device *dev, const char *file_name);
-#else
static inline void
devlink_compat_running_version(struct net_device *dev, char *buf, size_t len)
{