Commit 7112a046 authored by Sudheer Mogilappagari's avatar Sudheer Mogilappagari Committed by Jakub Kicinski
Browse files

ethtool: add netlink based get rss support



Add netlink based support for "ethtool -x <dev> [context x]"
command by implementing ETHTOOL_MSG_RSS_GET netlink message.
This is equivalent to functionality provided via ETHTOOL_GRSSH
in ioctl path. It sends RSS table, hash key and hash function
of an interface to user space.

This patch implements existing functionality available
in ioctl path and enables addition of new RSS context
based parameters in future.

Signed-off-by: default avatarSudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Link: https://lore.kernel.org/r/20221202002555.241580-1-sudheer.mogilappagari@intel.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 343a5d35
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ Userspace to kernel:
  ``ETHTOOL_MSG_MODULE_GET``            get transceiver module parameters
  ``ETHTOOL_MSG_PSE_SET``               set PSE parameters
  ``ETHTOOL_MSG_PSE_GET``               get PSE parameters
  ``ETHTOOL_MSG_RSS_GET``               get RSS settings
  ===================================== =================================

Kernel to userspace:
@@ -263,6 +264,7 @@ Kernel to userspace:
  ``ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY``    PHC virtual clocks info
  ``ETHTOOL_MSG_MODULE_GET_REPLY``         transceiver module parameters
  ``ETHTOOL_MSG_PSE_GET_REPLY``            PSE parameters
  ``ETHTOOL_MSG_RSS_GET_REPLY``            RSS settings
  ======================================== =================================

``GET`` requests are sent by userspace applications to retrieve device
@@ -1687,6 +1689,33 @@ to control PoDL PSE Admin functions. This option is implementing
``IEEE 802.3-2018`` 30.15.1.2.1 acPoDLPSEAdminControl. See
``ETHTOOL_A_PODL_PSE_ADMIN_STATE`` for supported values.

RSS_GET
=======

Get indirection table, hash key and hash function info associated with a
RSS context of an interface similar to ``ETHTOOL_GRSSH`` ioctl request.

Request contents:

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

Kernel response contents:

=====================================  ======  ==========================
  ``ETHTOOL_A_RSS_HEADER``             nested  reply header
  ``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_HFUNC attribute is bitmap indicating the hash function
being used. Current supported options are toeplitz, xor or crc32.
ETHTOOL_A_RSS_INDIR attribute returns RSS indrection table where each byte
indicates queue number.

Request translation
===================

@@ -1768,7 +1797,7 @@ are netlink only.
  ``ETHTOOL_GMODULEEEPROM``           ``ETHTOOL_MSG_MODULE_EEPROM_GET``
  ``ETHTOOL_GEEE``                    ``ETHTOOL_MSG_EEE_GET``
  ``ETHTOOL_SEEE``                    ``ETHTOOL_MSG_EEE_SET``
  ``ETHTOOL_GRSSH``                   n/a
  ``ETHTOOL_GRSSH``                   ``ETHTOOL_MSG_RSS_GET``
  ``ETHTOOL_SRSSH``                   n/a
  ``ETHTOOL_GTUNABLE``                n/a
  ``ETHTOOL_STUNABLE``                n/a
+14 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ enum {
	ETHTOOL_MSG_MODULE_SET,
	ETHTOOL_MSG_PSE_GET,
	ETHTOOL_MSG_PSE_SET,
	ETHTOOL_MSG_RSS_GET,

	/* add new constants above here */
	__ETHTOOL_MSG_USER_CNT,
@@ -97,6 +98,7 @@ enum {
	ETHTOOL_MSG_MODULE_GET_REPLY,
	ETHTOOL_MSG_MODULE_NTF,
	ETHTOOL_MSG_PSE_GET_REPLY,
	ETHTOOL_MSG_RSS_GET_REPLY,

	/* add new constants above here */
	__ETHTOOL_MSG_KERNEL_CNT,
@@ -880,6 +882,18 @@ enum {
	ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
};

enum {
	ETHTOOL_A_RSS_UNSPEC,
	ETHTOOL_A_RSS_HEADER,
	ETHTOOL_A_RSS_CONTEXT,		/* u32 */
	ETHTOOL_A_RSS_HFUNC,		/* u32 */
	ETHTOOL_A_RSS_INDIR,		/* binary */
	ETHTOOL_A_RSS_HKEY,		/* binary */

	__ETHTOOL_A_RSS_CNT,
	ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1),
};

/* generic netlink info */
#define ETHTOOL_GENL_NAME "ethtool"
#define ETHTOOL_GENL_VERSION 1
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ obj-y += ioctl.o common.o

obj-$(CONFIG_ETHTOOL_NETLINK)	+= ethtool_nl.o

ethtool_nl-y	:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o \
ethtool_nl-y	:= netlink.o bitset.o strset.o linkinfo.o linkmodes.o rss.o \
		   linkstate.o debug.o wol.o features.o privflags.o rings.o \
		   channels.o coalesce.o pause.o eee.o tsinfo.o cabletest.o \
		   tunnels.o fec.o eeprom.o stats.o phc_vclocks.o module.o \
+7 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = {
	[ETHTOOL_MSG_PHC_VCLOCKS_GET]	= &ethnl_phc_vclocks_request_ops,
	[ETHTOOL_MSG_MODULE_GET]	= &ethnl_module_request_ops,
	[ETHTOOL_MSG_PSE_GET]		= &ethnl_pse_request_ops,
	[ETHTOOL_MSG_RSS_GET]		= &ethnl_rss_request_ops,
};

static struct ethnl_dump_ctx *ethnl_dump_context(struct netlink_callback *cb)
@@ -1040,6 +1041,12 @@ static const struct genl_ops ethtool_genl_ops[] = {
		.policy = ethnl_pse_set_policy,
		.maxattr = ARRAY_SIZE(ethnl_pse_set_policy) - 1,
	},
	{
		.cmd	= ETHTOOL_MSG_RSS_GET,
		.doit	= ethnl_default_doit,
		.policy = ethnl_rss_get_policy,
		.maxattr = ARRAY_SIZE(ethnl_rss_get_policy) - 1,
	},
};

static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
+2 −0
Original line number Diff line number Diff line
@@ -346,6 +346,7 @@ extern const struct ethnl_request_ops ethnl_stats_request_ops;
extern const struct ethnl_request_ops ethnl_phc_vclocks_request_ops;
extern const struct ethnl_request_ops ethnl_module_request_ops;
extern const struct ethnl_request_ops ethnl_pse_request_ops;
extern const struct ethnl_request_ops ethnl_rss_request_ops;

extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];
@@ -386,6 +387,7 @@ extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER +
extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY + 1];
extern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1];
extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1];
extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_CONTEXT + 1];

int ethnl_set_linkinfo(struct sk_buff *skb, struct genl_info *info);
int ethnl_set_linkmodes(struct sk_buff *skb, struct genl_info *info);
Loading