netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	ecree.xilinx@gmail.com, michael.chan@broadcom.com,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 01/11] net: ethtool: let drivers remove lost RSS contexts
Date: Tue,  2 Jul 2024 16:47:46 -0700	[thread overview]
Message-ID: <20240702234757.4188344-2-kuba@kernel.org> (raw)
In-Reply-To: <20240702234757.4188344-1-kuba@kernel.org>

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.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 include/linux/ethtool.h |  2 ++
 net/ethtool/rss.c       | 14 ++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index f74bb0cf8ed1..3ce5be0d168a 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -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)
diff --git a/net/ethtool/rss.c b/net/ethtool/rss.c
index 71679137eff2..e2e5bab56a6b 100644
--- a/net/ethtool/rss.c
+++ b/net/ethtool/rss.c
@@ -159,3 +159,17 @@ const struct ethnl_request_ops ethnl_rss_request_ops = {
 	.fill_reply		= rss_fill_reply,
 	.cleanup_data		= rss_cleanup_data,
 };
+
+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);
-- 
2.45.2


  reply	other threads:[~2024-07-02 23:48 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 23:47 [PATCH net-next 00/11] eth: bnxt: use the new RSS API Jakub Kicinski
2024-07-02 23:47 ` Jakub Kicinski [this message]
2024-07-03 11:08   ` [PATCH net-next 01/11] net: ethtool: let drivers remove lost RSS contexts Edward Cree
2024-07-03 13:43     ` Jakub Kicinski
2024-07-03 14:15       ` Edward Cree
2024-07-02 23:47 ` [PATCH net-next 02/11] net: ethtool: let driver declare max size of RSS indir table and key Jakub Kicinski
2024-07-04  7:34   ` Simon Horman
2024-07-02 23:47 ` [PATCH net-next 02/11] net: ethtool: let drivers " Jakub Kicinski
2024-07-03 11:16   ` Edward Cree
2024-07-02 23:47 ` [PATCH net-next 03/11] eth: bnxt: allow deleting RSS contexts when the device is down Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 04/11] eth: bnxt: move from .set_rxfh to .create_rxfh_context and friends Jakub Kicinski
2024-07-03 12:06   ` Edward Cree
2024-07-03 12:49     ` Pavan Chebbi
2024-07-03 13:46       ` Jakub Kicinski
2024-07-04  6:19   ` kernel test robot
2024-07-05  0:34   ` kernel test robot
2024-07-02 23:47 ` [PATCH net-next 05/11] eth: bnxt: remove rss_ctx_bmap Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 06/11] eth: bnxt: depend on core cleaning up RSS contexts Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 07/11] eth: bnxt: use context priv for struct bnxt_rss_ctx Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 08/11] eth: bnxt: use the RSS context XArray instead of the local list Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 09/11] eth: bnxt: bump the entry size in indir tables to u32 Jakub Kicinski
2024-07-03 10:51   ` Przemek Kitszel
2024-07-03 13:49     ` Jakub Kicinski
2024-07-03 14:02       ` Przemek Kitszel
2024-07-03 16:02         ` Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 10/11] eth: bnxt: use the indir table from ethtool context Jakub Kicinski
2024-07-03 11:08   ` Przemek Kitszel
2024-07-03 11:39   ` Edward Cree
2024-07-03 13:51     ` Jakub Kicinski
2024-07-02 23:47 ` [PATCH net-next 11/11] eth: bnxt: pad out the correct indirection table Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2024-07-11 22:07 [PATCH net-next 00/11] eth: bnxt: use the new RSS API Jakub Kicinski
2024-07-11 22:07 ` [PATCH net-next 01/11] net: ethtool: let drivers remove lost RSS contexts Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240702234757.4188344-2-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=ecree.xilinx@gmail.com \
    --cc=edumazet@google.com \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).