Commit a166ab78 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

ethtool: rss: support creating contexts via Netlink

Support creating contexts via Netlink. Setting flow hashing
fields on the new context is not supported at this stage,
it can be added later.

An empty indirection table is not supported. This is a carry
over from the IOCTL interface where empty indirection table
meant delete. We can repurpose empty indirection table in
Netlink but for now to avoid confusion reject it using the
policy.

Support letting user choose the ID for the new context. This was
not possible in IOCTL since the context ID field for the create
action had to be set to the ETH_RXFH_CONTEXT_ALLOC magic value.

Link: https://patch.msgid.link/20250717234343.2328602-7-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 55ef461c
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -2684,9 +2684,28 @@ operations:
      name: rss-ntf
      doc: |
        Notification for change in RSS configuration.
        For additional contexts only modifications are modified, not creation
        or removal of the contexts.
        For additional contexts only modifications use this notification,
        creation and deletion have dedicated messages.
      notify: rss-get
    -
      name: rss-create-act
      doc: Create an RSS context.
      attribute-set: rss
      do:
        request: &rss-create-attrs
          attributes:
            - header
            - context
            - hfunc
            - indir
            - hkey
            - input-xfrm
        reply: *rss-create-attrs
    -
      name: rss-create-ntf
      doc: |
        Notification for creation of an additional RSS context.
      notify: rss-create-act

mcast-groups:
  list:
+27 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ Userspace to kernel:
  ``ETHTOOL_MSG_TSCONFIG_GET``          get hw timestamping configuration
  ``ETHTOOL_MSG_TSCONFIG_SET``          set hw timestamping configuration
  ``ETHTOOL_MSG_RSS_SET``               set RSS settings
  ``ETHTOOL_MSG_RSS_CREATE_ACT``        create an additional RSS context
  ===================================== =================================

Kernel to userspace:
@@ -294,6 +295,8 @@ Kernel to userspace:
  ``ETHTOOL_MSG_TSCONFIG_SET_REPLY``       new hw timestamping configuration
  ``ETHTOOL_MSG_PSE_NTF``                  PSE events notification
  ``ETHTOOL_MSG_RSS_NTF``                  RSS settings notification
  ``ETHTOOL_MSG_RSS_CREATE_ACT_REPLY``     create an additional RSS context
  ``ETHTOOL_MSG_RSS_CREATE_NTF``           additional RSS context created
  ======================================== =================================

``GET`` requests are sent by userspace applications to retrieve device
@@ -2014,6 +2017,30 @@ device needs at least 8 entries - the real table in use will end up being
of 2, so tables which size is not a power of 2 will likely be rejected.
Using table of size 0 will reset the indirection table to the default.

RSS_CREATE_ACT
==============

Request contents:

=====================================  ======  ==============================
  ``ETHTOOL_A_RSS_HEADER``             nested  request header
  ``ETHTOOL_A_RSS_CONTEXT``            u32     context number
  ``ETHTOOL_A_RSS_HFUNC``              u32     RSS hash func
  ``ETHTOOL_A_RSS_INDIR``              binary  Indir table bytes
  ``ETHTOOL_A_RSS_HKEY``               binary  Hash key bytes
  ``ETHTOOL_A_RSS_INPUT_XFRM``         u32     RSS input data transformation
=====================================  ======  ==============================

Kernel response contents:

=====================================  ======  ==============================
  ``ETHTOOL_A_RSS_HEADER``             nested  request header
  ``ETHTOOL_A_RSS_CONTEXT``            u32     context number
=====================================  ======  ==============================

Create an additional RSS context, if ``ETHTOOL_A_RSS_CONTEXT`` is not
specified kernel will allocate one automatically.

PLCA_GET_CFG
============

+3 −0
Original line number Diff line number Diff line
@@ -841,6 +841,7 @@ enum {
	ETHTOOL_MSG_TSCONFIG_GET,
	ETHTOOL_MSG_TSCONFIG_SET,
	ETHTOOL_MSG_RSS_SET,
	ETHTOOL_MSG_RSS_CREATE_ACT,

	__ETHTOOL_MSG_USER_CNT,
	ETHTOOL_MSG_USER_MAX = (__ETHTOOL_MSG_USER_CNT - 1)
@@ -898,6 +899,8 @@ enum {
	ETHTOOL_MSG_TSCONFIG_SET_REPLY,
	ETHTOOL_MSG_PSE_NTF,
	ETHTOOL_MSG_RSS_NTF,
	ETHTOOL_MSG_RSS_CREATE_ACT_REPLY,
	ETHTOOL_MSG_RSS_CREATE_NTF,

	__ETHTOOL_MSG_KERNEL_CNT,
	ETHTOOL_MSG_KERNEL_MAX = (__ETHTOOL_MSG_KERNEL_CNT - 1)
+1 −0
Original line number Diff line number Diff line
@@ -1640,6 +1640,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
		ntf = ETHTOOL_MSG_RSS_NTF;
		ret = ops->set_rxfh(dev, &rxfh_dev, extack);
	} else if (create) {
		ntf = ETHTOOL_MSG_RSS_CREATE_NTF;
		ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev, extack);
		/* Make sure driver populates defaults */
		WARN_ON_ONCE(!ret && !rxfh_dev.key && ops->rxfh_per_ctx_key &&
+15 −0
Original line number Diff line number Diff line
@@ -81,6 +81,12 @@ static void ethnl_sock_priv_destroy(void *priv)
	}
}

u32 ethnl_bcast_seq_next(void)
{
	ASSERT_RTNL();
	return ++ethnl_bcast_seq;
}

int ethnl_ops_begin(struct net_device *dev)
{
	int ret;
@@ -954,6 +960,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
	[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,
	[ETHTOOL_MSG_RSS_CREATE_NTF]	= &ethnl_rss_request_ops,
};

/* default notification handler */
@@ -1061,6 +1068,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
	[ETHTOOL_MSG_PLCA_NTF]		= ethnl_default_notify,
	[ETHTOOL_MSG_MM_NTF]		= ethnl_default_notify,
	[ETHTOOL_MSG_RSS_NTF]		= ethnl_default_notify,
	[ETHTOOL_MSG_RSS_CREATE_NTF]	= ethnl_default_notify,
};

void ethnl_notify(struct net_device *dev, unsigned int cmd,
@@ -1512,6 +1520,13 @@ static const struct genl_ops ethtool_genl_ops[] = {
		.policy = ethnl_rss_set_policy,
		.maxattr = ARRAY_SIZE(ethnl_rss_set_policy) - 1,
	},
	{
		.cmd	= ETHTOOL_MSG_RSS_CREATE_ACT,
		.flags	= GENL_UNS_ADMIN_PERM,
		.doit	= ethnl_rss_create_doit,
		.policy	= ethnl_rss_create_policy,
		.maxattr = ARRAY_SIZE(ethnl_rss_create_policy) - 1,
	},
};

static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
Loading