]> www.infradead.org Git - nvme.git/commitdiff
net: ethtool: let drivers remove lost RSS contexts
authorJakub Kicinski <kuba@kernel.org>
Thu, 11 Jul 2024 22:07:03 +0000 (15:07 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jul 2024 05:16:21 +0000 (22:16 -0700)
RSS contexts may get lost from a device, in various extreme circumstances.
Specifically if the firmware leaks resources and resets, or crashes and
either recovers in partially working state or the crash causes a
different FW version to run - creating the context again may fail.

Drivers should do their absolute best to prevent this from happening.
When it does, however, telling user that a context exists, when it can't
possibly be used any more is counter productive. Add a helper for
drivers to discard contexts. Print an error, in the future netlink
notification will also be sent.

More robust approaches were proposed, like keeping the contexts
but marking them as "dead" (but possibly resurrected by next reset).
That may be better but it's unclear at this stage whether the
effort is worth the benefits.

Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Link: https://patch.msgid.link/20240711220713.283778-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/ethtool.h
net/ethtool/common.c

index e213b5508da64f68718fa1a3a6f38faa24289205..89da0254ccd4cc747a4805aa17bda92c31382c74 100644 (file)
@@ -210,6 +210,8 @@ static inline size_t ethtool_rxfh_context_size(u32 indir_size, u32 key_size,
        return struct_size_t(struct ethtool_rxfh_context, data, flex_len);
 }
 
+void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id);
+
 /* declare a link mode bitmap */
 #define __ETHTOOL_DECLARE_LINK_MODE_MASK(name)         \
        DECLARE_BITMAP(name, __ETHTOOL_LINK_MODE_MASK_NBITS)
index 7bda9600efcfd8ef409f62ca80ab22fc30ffd59a..67d06cd002a538140888930ed0820cf6175d4bc0 100644 (file)
@@ -741,3 +741,17 @@ ethtool_forced_speed_maps_init(struct ethtool_forced_speed_map *maps, u32 size)
        }
 }
 EXPORT_SYMBOL_GPL(ethtool_forced_speed_maps_init);
+
+void ethtool_rxfh_context_lost(struct net_device *dev, u32 context_id)
+{
+       struct ethtool_rxfh_context *ctx;
+
+       WARN_ONCE(!rtnl_is_locked() &&
+                 !lockdep_is_held_type(&dev->ethtool->rss_lock, -1),
+                 "RSS context lock assertion failed\n");
+
+       netdev_err(dev, "device error, RSS context %d lost\n", context_id);
+       ctx = xa_erase(&dev->ethtool->rss_ctx, context_id);
+       kfree(ctx);
+}
+EXPORT_SYMBOL(ethtool_rxfh_context_lost);