]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ethtool: rss: add notifications
authorJakub Kicinski <kuba@kernel.org>
Mon, 23 Jun 2025 23:17:18 +0000 (16:17 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Jun 2025 22:24:14 +0000 (15:24 -0700)
In preparation for RSS_SET handling in ethnl introduce Netlink
notifications for RSS. Only cover modifications, not creation
and not removal of a context, because the latter may deserve
a different notification type. We should cross that bridge
when we add the support for context add / remove via Netlink.

Link: https://patch.msgid.link/20250623231720.3124717-7-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/netlink/specs/ethtool.yaml
Documentation/networking/ethtool-netlink.rst
include/uapi/linux/ethtool_netlink_generated.h
net/ethtool/common.h
net/ethtool/ioctl.c
net/ethtool/netlink.c
net/ethtool/rss.c

index cfe84f84ba29301b941e26c520cb3d79052ba06e..19a32229772af73bb7c63cbb6bf32c43b5d3b528 100644 (file)
@@ -2492,6 +2492,13 @@ operations:
         attributes:
           - header
           - events
+    -
+      name: rss-ntf
+      doc: |
+        Notification for change in RSS configuration.
+        For additional contexts only modifications are modified, not creation
+        or removal of the contexts.
+      notify: rss-get
 
 mcast-groups:
   list:
index e45bb555e909002f157ae3060669435db7df97d5..08abca99a6dc32f5373fef92b555178ccc8afdda 100644 (file)
@@ -281,6 +281,7 @@ Kernel to userspace:
   ``ETHTOOL_MSG_MODULE_GET_REPLY``         transceiver module parameters
   ``ETHTOOL_MSG_PSE_GET_REPLY``            PSE parameters
   ``ETHTOOL_MSG_RSS_GET_REPLY``            RSS settings
+  ``ETHTOOL_MSG_RSS_NTF``                  RSS settings
   ``ETHTOOL_MSG_PLCA_GET_CFG_REPLY``       PLCA RS parameters
   ``ETHTOOL_MSG_PLCA_GET_STATUS_REPLY``    PLCA RS status
   ``ETHTOOL_MSG_PLCA_NTF``                 PLCA RS parameters
index 859e28c8a91a2d4040908bcbb4dff390245b8a80..8f30ffa1cd143cc759e4555a9c475c06277ca8ab 100644 (file)
@@ -862,6 +862,7 @@ enum {
        ETHTOOL_MSG_TSCONFIG_GET_REPLY,
        ETHTOOL_MSG_TSCONFIG_SET_REPLY,
        ETHTOOL_MSG_PSE_NTF,
+       ETHTOOL_MSG_RSS_NTF,
 
        __ETHTOOL_MSG_KERNEL_CNT,
        ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1)
index b4683d286a5a51e8446951f9e3ebb1a353f45756..c41db1595621e135a3025b564c96afcdb49f5bd8 100644 (file)
@@ -74,4 +74,12 @@ int ethtool_get_module_eeprom_call(struct net_device *dev,
 
 bool __ethtool_dev_mm_supported(struct net_device *dev);
 
+#if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
+void ethtool_rss_notify(struct net_device *dev, u32 rss_context);
+#else
+static inline void ethtool_rss_notify(struct net_device *dev, u32 rss_context)
+{
+}
+#endif
+
 #endif /* _ETHTOOL_COMMON_H */
index 96da9d18789ba97b53862ac2ee258854766f9250..c34bac7bffd8cbf5fb7608ee58bc19d12a3c6543 100644 (file)
@@ -1502,6 +1502,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
        struct ethtool_rxfh rxfh;
        bool locked = false; /* dev->ethtool->rss_lock taken */
        bool create = false;
+       bool mod = false;
        u8 *rss_config;
        int ret;
 
@@ -1688,6 +1689,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
                }
                goto out;
        }
+       mod = !create && !rxfh_dev.rss_delete;
 
        if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_context),
                         &rxfh_dev.rss_context, sizeof(rxfh_dev.rss_context)))
@@ -1757,6 +1759,8 @@ out:
        if (locked)
                mutex_unlock(&dev->ethtool->rss_lock);
        kfree(rss_config);
+       if (mod)
+               ethtool_rss_notify(dev, rxfh.rss_context);
        return ret;
 }
 
index 60b3c07507d293721993b013355b8f325207ac5e..09c81cc9a08f0dc8361855d0126abf6627d3000e 100644 (file)
@@ -946,6 +946,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
        [ETHTOOL_MSG_MODULE_NTF]        = &ethnl_module_request_ops,
        [ETHTOOL_MSG_PLCA_NTF]          = &ethnl_plca_cfg_request_ops,
        [ETHTOOL_MSG_MM_NTF]            = &ethnl_mm_request_ops,
+       [ETHTOOL_MSG_RSS_NTF]           = &ethnl_rss_request_ops,
 };
 
 /* default notification handler */
@@ -1052,6 +1053,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
        [ETHTOOL_MSG_MODULE_NTF]        = ethnl_default_notify,
        [ETHTOOL_MSG_PLCA_NTF]          = ethnl_default_notify,
        [ETHTOOL_MSG_MM_NTF]            = ethnl_default_notify,
+       [ETHTOOL_MSG_RSS_NTF]           = ethnl_default_notify,
 };
 
 void ethnl_notify(struct net_device *dev, unsigned int cmd,
index 6d9b1769896ba1c1b8b0a53d31f315c61ea0938c..3adddca7e215ffc0ac454bd4cc19f6d0df8d707a 100644 (file)
@@ -358,6 +358,17 @@ int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
        return ret;
 }
 
+/* RSS_NTF */
+
+void ethtool_rss_notify(struct net_device *dev, u32 rss_context)
+{
+       struct rss_req_info req_info = {
+               .rss_context = rss_context,
+       };
+
+       ethnl_notify(dev, ETHTOOL_MSG_RSS_NTF, &req_info.base);
+}
+
 const struct ethnl_request_ops ethnl_rss_request_ops = {
        .request_cmd            = ETHTOOL_MSG_RSS_GET,
        .reply_cmd              = ETHTOOL_MSG_RSS_GET_REPLY,