Skip to content

Commit 46837be

Browse files
committed
net: ethtool: rss: add notifications
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>
1 parent 3073947 commit 46837be

File tree

7 files changed

+34
-0
lines changed

7 files changed

+34
-0
lines changed

Documentation/netlink/specs/ethtool.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,13 @@ operations:
24922492
attributes:
24932493
- header
24942494
- events
2495+
-
2496+
name: rss-ntf
2497+
doc: |
2498+
Notification for change in RSS configuration.
2499+
For additional contexts only modifications are modified, not creation
2500+
or removal of the contexts.
2501+
notify: rss-get
24952502

24962503
mcast-groups:
24972504
list:

Documentation/networking/ethtool-netlink.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ Kernel to userspace:
281281
``ETHTOOL_MSG_MODULE_GET_REPLY`` transceiver module parameters
282282
``ETHTOOL_MSG_PSE_GET_REPLY`` PSE parameters
283283
``ETHTOOL_MSG_RSS_GET_REPLY`` RSS settings
284+
``ETHTOOL_MSG_RSS_NTF`` RSS settings
284285
``ETHTOOL_MSG_PLCA_GET_CFG_REPLY`` PLCA RS parameters
285286
``ETHTOOL_MSG_PLCA_GET_STATUS_REPLY`` PLCA RS status
286287
``ETHTOOL_MSG_PLCA_NTF`` PLCA RS parameters

include/uapi/linux/ethtool_netlink_generated.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ enum {
862862
ETHTOOL_MSG_TSCONFIG_GET_REPLY,
863863
ETHTOOL_MSG_TSCONFIG_SET_REPLY,
864864
ETHTOOL_MSG_PSE_NTF,
865+
ETHTOOL_MSG_RSS_NTF,
865866

866867
__ETHTOOL_MSG_KERNEL_CNT,
867868
ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1)

net/ethtool/common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,12 @@ int ethtool_get_module_eeprom_call(struct net_device *dev,
7474

7575
bool __ethtool_dev_mm_supported(struct net_device *dev);
7676

77+
#if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
78+
void ethtool_rss_notify(struct net_device *dev, u32 rss_context);
79+
#else
80+
static inline void ethtool_rss_notify(struct net_device *dev, u32 rss_context)
81+
{
82+
}
83+
#endif
84+
7785
#endif /* _ETHTOOL_COMMON_H */

net/ethtool/ioctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
15021502
struct ethtool_rxfh rxfh;
15031503
bool locked = false; /* dev->ethtool->rss_lock taken */
15041504
bool create = false;
1505+
bool mod = false;
15051506
u8 *rss_config;
15061507
int ret;
15071508

@@ -1688,6 +1689,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
16881689
}
16891690
goto out;
16901691
}
1692+
mod = !create && !rxfh_dev.rss_delete;
16911693

16921694
if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_context),
16931695
&rxfh_dev.rss_context, sizeof(rxfh_dev.rss_context)))
@@ -1757,6 +1759,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
17571759
if (locked)
17581760
mutex_unlock(&dev->ethtool->rss_lock);
17591761
kfree(rss_config);
1762+
if (mod)
1763+
ethtool_rss_notify(dev, rxfh.rss_context);
17601764
return ret;
17611765
}
17621766

net/ethtool/netlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
946946
[ETHTOOL_MSG_MODULE_NTF] = &ethnl_module_request_ops,
947947
[ETHTOOL_MSG_PLCA_NTF] = &ethnl_plca_cfg_request_ops,
948948
[ETHTOOL_MSG_MM_NTF] = &ethnl_mm_request_ops,
949+
[ETHTOOL_MSG_RSS_NTF] = &ethnl_rss_request_ops,
949950
};
950951

951952
/* default notification handler */
@@ -1052,6 +1053,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
10521053
[ETHTOOL_MSG_MODULE_NTF] = ethnl_default_notify,
10531054
[ETHTOOL_MSG_PLCA_NTF] = ethnl_default_notify,
10541055
[ETHTOOL_MSG_MM_NTF] = ethnl_default_notify,
1056+
[ETHTOOL_MSG_RSS_NTF] = ethnl_default_notify,
10551057
};
10561058

10571059
void ethnl_notify(struct net_device *dev, unsigned int cmd,

net/ethtool/rss.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ int ethnl_rss_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
358358
return ret;
359359
}
360360

361+
/* RSS_NTF */
362+
363+
void ethtool_rss_notify(struct net_device *dev, u32 rss_context)
364+
{
365+
struct rss_req_info req_info = {
366+
.rss_context = rss_context,
367+
};
368+
369+
ethnl_notify(dev, ETHTOOL_MSG_RSS_NTF, &req_info.base);
370+
}
371+
361372
const struct ethnl_request_ops ethnl_rss_request_ops = {
362373
.request_cmd = ETHTOOL_MSG_RSS_GET,
363374
.reply_cmd = ETHTOOL_MSG_RSS_GET_REPLY,

0 commit comments

Comments
 (0)