summaryrefslogtreecommitdiffstats
path: root/net/core/devlink.c
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-02-14 22:40:45 +0100
committerDavid S. Miller <davem@davemloft.net>2019-02-18 00:27:38 +0100
commit4eceba17200c03a2678edbdcff5d800aded607be (patch)
tree0cd0a1b32c2e5ee05076378de22418abb3d0c9de /net/core/devlink.c
parentdevlink: add flash update command (diff)
downloadlinux-4eceba17200c03a2678edbdcff5d800aded607be.tar.xz
linux-4eceba17200c03a2678edbdcff5d800aded607be.zip
ethtool: add compat for flash update
If driver does not support ethtool flash update operation call into devlink. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/devlink.c')
-rw-r--r--net/core/devlink.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 4a1ad0b13e52..04d98550c78c 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6450,6 +6450,36 @@ out:
mutex_unlock(&devlink_mutex);
}
+int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
+{
+ struct devlink_port *devlink_port;
+ struct devlink *devlink;
+
+ mutex_lock(&devlink_mutex);
+ list_for_each_entry(devlink, &devlink_list, list) {
+ mutex_lock(&devlink->lock);
+ list_for_each_entry(devlink_port, &devlink->port_list, list) {
+ int ret = -EOPNOTSUPP;
+
+ if (devlink_port->type != DEVLINK_PORT_TYPE_ETH ||
+ devlink_port->type_dev != dev)
+ continue;
+
+ mutex_unlock(&devlink_mutex);
+ if (devlink->ops->flash_update)
+ ret = devlink->ops->flash_update(devlink,
+ file_name,
+ NULL, NULL);
+ mutex_unlock(&devlink->lock);
+ return ret;
+ }
+ mutex_unlock(&devlink->lock);
+ }
+ mutex_unlock(&devlink_mutex);
+
+ return -EOPNOTSUPP;
+}
+
static int __init devlink_module_init(void)
{
return genl_register_family(&devlink_nl_family);