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

Merge branch 'ethtool-rss-report-which-fields-are-configured-for-hashing'

Jakub Kicinski says:

====================
ethtool: rss: report which fields are configured for hashing

Add support for reading flow hash configuration via Netlink ethtool.

  $ ynl --family ethtool --dump rss-get
     [{
        "header": {
            "dev-index": 1,
            "dev-name": "enp1s0"
        },
        "hfunc": 1,
        "hkey": b"...",
        "indir": [0, 1, ...],
        "flow-hash": {
            "ether": {"l2da"},
            "ah-esp4": {"ip-src", "ip-dst"},
            "ah-esp6": {"ip-src", "ip-dst"},
            "ah4": {"ip-src", "ip-dst"},
            "ah6": {"ip-src", "ip-dst"},
            "esp4": {"ip-src", "ip-dst"},
            "esp6": {"ip-src", "ip-dst"},
            "ip4": {"ip-src", "ip-dst"},
            "ip6": {"ip-src", "ip-dst"},
            "sctp4": {"ip-src", "ip-dst"},
            "sctp6": {"ip-src", "ip-dst"},
            "udp4": {"ip-src", "ip-dst"},
            "udp6": {"ip-src", "ip-dst"}
            "tcp4": {"l4-b-0-1", "l4-b-2-3", "ip-src", "ip-dst"},
            "tcp6": {"l4-b-0-1", "l4-b-2-3", "ip-src", "ip-dst"},
        },
     }]
====================

Link: https://patch.msgid.link/20250708220640.2738464-1-kuba@kernel.org


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 809f6833 0c8754b7
Loading
Loading
Loading
Loading
+151 −0
Original line number Diff line number Diff line
@@ -158,6 +158,35 @@ definitions:
      -
        name: pse-event-sw-pw-control-error
        doc: PSE faced an error managing the power control from software
  -
    name: rxfh-fields
    name-prefix: rxh-
    enum-name:
    header: linux/ethtool.h
    type: flags
    entries:
      -
        name: l2da
        value: 1
      -
        name: vlan
      -
        name: l3-proto
      -
        name: ip-src
      -
        name: ip-dst
      -
        name: l4-b-0-1
        doc: src port in case of TCP/UDP/SCTP
      -
        name: l4-b-2-3
        doc: dst port in case of TCP/UDP/SCTP
      -
        name: gtp-teid
      -
        name: discard
        value: 31

attribute-sets:
  -
@@ -1447,6 +1476,123 @@ attribute-sets:
        name: pse-prio
        type: u32
        name-prefix: ethtool-a-
  -
    name: flow
    attr-cnt-name: --ethtool-a-flow-cnt
    doc: |
      Flow types, corresponding to those defined in the old
      ethtool header for RXFH and RXNFC as ${PROTO}_FLOW.
      The values are not matching the old ones to avoid carrying
      into Netlink the IP_USER_FLOW vs IPV4_FLOW vs IPV4_USER_FLOW confusion.
    attributes:
      -
        name: ether
        type: uint
        enum: rxfh-fields
      -
        name: ip4
        type: uint
        enum: rxfh-fields
      -
        name: ip6
        type: uint
        enum: rxfh-fields
      -
        name: tcp4
        type: uint
        enum: rxfh-fields
      -
        name: tcp6
        type: uint
        enum: rxfh-fields
      -
        name: udp4
        type: uint
        enum: rxfh-fields
      -
        name: udp6
        type: uint
        enum: rxfh-fields
      -
        name: sctp4
        type: uint
        enum: rxfh-fields
      -
        name: sctp6
        type: uint
        enum: rxfh-fields
      -
        name: ah4
        type: uint
        enum: rxfh-fields
      -
        name: ah6
        type: uint
        enum: rxfh-fields
      -
        name: esp4
        type: uint
        enum: rxfh-fields
      -
        name: esp6
        type: uint
        enum: rxfh-fields
      -
        name: ah-esp4
        type: uint
        enum: rxfh-fields
      -
        name: ah-esp6
        type: uint
        enum: rxfh-fields
      -
        name: gtpu4
        type: uint
        enum: rxfh-fields
      -
        name: gtpu6
        type: uint
        enum: rxfh-fields
      -
        name: gtpc4
        type: uint
        enum: rxfh-fields
      -
        name: gtpc6
        type: uint
        enum: rxfh-fields
      -
        name: gtpc-teid4
        type: uint
        enum: rxfh-fields
      -
        name: gtpc-teid6
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-eh4
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-eh6
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-ul4
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-ul6
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-dl4
        type: uint
        enum: rxfh-fields
      -
        name: gtpu-dl6
        type: uint
        enum: rxfh-fields
  -
    name: rss
    attr-cnt-name: __ethtool-a-rss-cnt
@@ -1478,6 +1624,10 @@ attribute-sets:
      -
        name: start-context
        type: u32
      -
        name: flow-hash
        type: nest
        nested-attributes: flow
  -
    name: plca
    attr-cnt-name: __ethtool-a-plca-cnt
@@ -2307,6 +2457,7 @@ operations:
            - indir
            - hkey
            - input-xfrm
            - flow-hash
      dump:
        request:
          attributes:
+6 −3
Original line number Diff line number Diff line
@@ -1969,14 +1969,15 @@ used to ignore context 0s and only dump additional contexts).

Kernel response contents:

=====================================  ======  ==========================
=====================================  ======  ===============================
  ``ETHTOOL_A_RSS_HEADER``             nested  reply 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
=====================================  ======  ==========================
  ``ETHTOOL_A_RSS_FLOW_HASH``          nested  Header fields included in hash
=====================================  ======  ===============================

ETHTOOL_A_RSS_HFUNC attribute is bitmap indicating the hash function
being used. Current supported options are toeplitz, xor or crc32.
@@ -1985,6 +1986,8 @@ indicates queue number.
ETHTOOL_A_RSS_INPUT_XFRM attribute is a bitmap indicating the type of
transformation applied to the input protocol fields before given to the RSS
hfunc. Current supported options are symmetric-xor and symmetric-or-xor.
ETHTOOL_A_RSS_FLOW_HASH carries per-flow type bitmask of which header
fields are included in the hash calculation.

PLCA_GET_CFG
============
@@ -2436,7 +2439,7 @@ are netlink only.
  ``ETHTOOL_SFLAGS``                  ``ETHTOOL_MSG_FEATURES_SET``
  ``ETHTOOL_GPFLAGS``                 ``ETHTOOL_MSG_PRIVFLAGS_GET``
  ``ETHTOOL_SPFLAGS``                 ``ETHTOOL_MSG_PRIVFLAGS_SET``
  ``ETHTOOL_GRXFH``                   n/a
  ``ETHTOOL_GRXFH``                   ``ETHTOOL_MSG_RSS_GET``
  ``ETHTOOL_SRXFH``                   n/a
  ``ETHTOOL_GGRO``                    ``ETHTOOL_MSG_FEATURES_GET``
  ``ETHTOOL_SGRO``                    ``ETHTOOL_MSG_FEATURES_SET``
+2 −2
Original line number Diff line number Diff line
@@ -2314,7 +2314,7 @@ enum {
	IPV6_USER_FLOW	= 0x0e, /* spec only (usr_ip6_spec; nfc only) */
	IPV4_FLOW	= 0x10, /* hash only */
	IPV6_FLOW	= 0x11, /* hash only */
	ETHER_FLOW	= 0x12, /* spec only (ether_spec) */
	ETHER_FLOW	= 0x12, /* hash or spec (ether_spec) */

	/* Used for GTP-U IPv4 and IPv6.
	 * The format of GTP packets only includes
@@ -2371,7 +2371,7 @@ enum {
/* Flag to enable RSS spreading of traffic matching rule (nfc only) */
#define	FLOW_RSS	0x20000000

/* L3-L4 network traffic flow hash options */
/* L2-L4 network traffic flow hash options */
#define	RXH_L2DA	(1 << 1)
#define	RXH_VLAN	(1 << 2)
#define	RXH_L3_PROTO	(1 << 3)
+34 −0
Original line number Diff line number Diff line
@@ -678,6 +678,39 @@ enum {
	ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
};

enum {
	ETHTOOL_A_FLOW_ETHER = 1,
	ETHTOOL_A_FLOW_IP4,
	ETHTOOL_A_FLOW_IP6,
	ETHTOOL_A_FLOW_TCP4,
	ETHTOOL_A_FLOW_TCP6,
	ETHTOOL_A_FLOW_UDP4,
	ETHTOOL_A_FLOW_UDP6,
	ETHTOOL_A_FLOW_SCTP4,
	ETHTOOL_A_FLOW_SCTP6,
	ETHTOOL_A_FLOW_AH4,
	ETHTOOL_A_FLOW_AH6,
	ETHTOOL_A_FLOW_ESP4,
	ETHTOOL_A_FLOW_ESP6,
	ETHTOOL_A_FLOW_AH_ESP4,
	ETHTOOL_A_FLOW_AH_ESP6,
	ETHTOOL_A_FLOW_GTPU4,
	ETHTOOL_A_FLOW_GTPU6,
	ETHTOOL_A_FLOW_GTPC4,
	ETHTOOL_A_FLOW_GTPC6,
	ETHTOOL_A_FLOW_GTPC_TEID4,
	ETHTOOL_A_FLOW_GTPC_TEID6,
	ETHTOOL_A_FLOW_GTPU_EH4,
	ETHTOOL_A_FLOW_GTPU_EH6,
	ETHTOOL_A_FLOW_GTPU_UL4,
	ETHTOOL_A_FLOW_GTPU_UL6,
	ETHTOOL_A_FLOW_GTPU_DL4,
	ETHTOOL_A_FLOW_GTPU_DL6,

	__ETHTOOL_A_FLOW_CNT,
	ETHTOOL_A_FLOW_MAX = (__ETHTOOL_A_FLOW_CNT - 1)
};

enum {
	ETHTOOL_A_RSS_UNSPEC,
	ETHTOOL_A_RSS_HEADER,
@@ -687,6 +720,7 @@ enum {
	ETHTOOL_A_RSS_HKEY,
	ETHTOOL_A_RSS_INPUT_XFRM,
	ETHTOOL_A_RSS_START_CONTEXT,
	ETHTOOL_A_RSS_FLOW_HASH,

	__ETHTOOL_A_RSS_CNT,
	ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1)
+6 −1
Original line number Diff line number Diff line
@@ -981,6 +981,7 @@ static int ethtool_rxnfc_copy_to_user(void __user *useraddr,
static bool flow_type_hashable(u32 flow_type)
{
	switch (flow_type) {
	case ETHER_FLOW:
	case TCP_V4_FLOW:
	case UDP_V4_FLOW:
	case SCTP_V4_FLOW:
@@ -1100,7 +1101,11 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
	rc = ops->set_rxfh_fields(dev, &fields, NULL);
exit_unlock:
	mutex_unlock(&dev->ethtool->rss_lock);
	if (rc)
		return rc;

	ethtool_rss_notify(dev, fields.rss_context);
	return 0;
}

static noinline_for_stack int
Loading