Skip to content

Commit acd7c71

Browse files
committed
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: Jakub Kicinski <kuba@kernel.org>
2 parents 809f683 + 0c8754b commit acd7c71

File tree

8 files changed

+364
-35
lines changed

8 files changed

+364
-35
lines changed

Documentation/netlink/specs/ethtool.yaml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,35 @@ definitions:
158158
-
159159
name: pse-event-sw-pw-control-error
160160
doc: PSE faced an error managing the power control from software
161+
-
162+
name: rxfh-fields
163+
name-prefix: rxh-
164+
enum-name:
165+
header: linux/ethtool.h
166+
type: flags
167+
entries:
168+
-
169+
name: l2da
170+
value: 1
171+
-
172+
name: vlan
173+
-
174+
name: l3-proto
175+
-
176+
name: ip-src
177+
-
178+
name: ip-dst
179+
-
180+
name: l4-b-0-1
181+
doc: src port in case of TCP/UDP/SCTP
182+
-
183+
name: l4-b-2-3
184+
doc: dst port in case of TCP/UDP/SCTP
185+
-
186+
name: gtp-teid
187+
-
188+
name: discard
189+
value: 31
161190

162191
attribute-sets:
163192
-
@@ -1447,6 +1476,123 @@ attribute-sets:
14471476
name: pse-prio
14481477
type: u32
14491478
name-prefix: ethtool-a-
1479+
-
1480+
name: flow
1481+
attr-cnt-name: --ethtool-a-flow-cnt
1482+
doc: |
1483+
Flow types, corresponding to those defined in the old
1484+
ethtool header for RXFH and RXNFC as ${PROTO}_FLOW.
1485+
The values are not matching the old ones to avoid carrying
1486+
into Netlink the IP_USER_FLOW vs IPV4_FLOW vs IPV4_USER_FLOW confusion.
1487+
attributes:
1488+
-
1489+
name: ether
1490+
type: uint
1491+
enum: rxfh-fields
1492+
-
1493+
name: ip4
1494+
type: uint
1495+
enum: rxfh-fields
1496+
-
1497+
name: ip6
1498+
type: uint
1499+
enum: rxfh-fields
1500+
-
1501+
name: tcp4
1502+
type: uint
1503+
enum: rxfh-fields
1504+
-
1505+
name: tcp6
1506+
type: uint
1507+
enum: rxfh-fields
1508+
-
1509+
name: udp4
1510+
type: uint
1511+
enum: rxfh-fields
1512+
-
1513+
name: udp6
1514+
type: uint
1515+
enum: rxfh-fields
1516+
-
1517+
name: sctp4
1518+
type: uint
1519+
enum: rxfh-fields
1520+
-
1521+
name: sctp6
1522+
type: uint
1523+
enum: rxfh-fields
1524+
-
1525+
name: ah4
1526+
type: uint
1527+
enum: rxfh-fields
1528+
-
1529+
name: ah6
1530+
type: uint
1531+
enum: rxfh-fields
1532+
-
1533+
name: esp4
1534+
type: uint
1535+
enum: rxfh-fields
1536+
-
1537+
name: esp6
1538+
type: uint
1539+
enum: rxfh-fields
1540+
-
1541+
name: ah-esp4
1542+
type: uint
1543+
enum: rxfh-fields
1544+
-
1545+
name: ah-esp6
1546+
type: uint
1547+
enum: rxfh-fields
1548+
-
1549+
name: gtpu4
1550+
type: uint
1551+
enum: rxfh-fields
1552+
-
1553+
name: gtpu6
1554+
type: uint
1555+
enum: rxfh-fields
1556+
-
1557+
name: gtpc4
1558+
type: uint
1559+
enum: rxfh-fields
1560+
-
1561+
name: gtpc6
1562+
type: uint
1563+
enum: rxfh-fields
1564+
-
1565+
name: gtpc-teid4
1566+
type: uint
1567+
enum: rxfh-fields
1568+
-
1569+
name: gtpc-teid6
1570+
type: uint
1571+
enum: rxfh-fields
1572+
-
1573+
name: gtpu-eh4
1574+
type: uint
1575+
enum: rxfh-fields
1576+
-
1577+
name: gtpu-eh6
1578+
type: uint
1579+
enum: rxfh-fields
1580+
-
1581+
name: gtpu-ul4
1582+
type: uint
1583+
enum: rxfh-fields
1584+
-
1585+
name: gtpu-ul6
1586+
type: uint
1587+
enum: rxfh-fields
1588+
-
1589+
name: gtpu-dl4
1590+
type: uint
1591+
enum: rxfh-fields
1592+
-
1593+
name: gtpu-dl6
1594+
type: uint
1595+
enum: rxfh-fields
14501596
-
14511597
name: rss
14521598
attr-cnt-name: __ethtool-a-rss-cnt
@@ -1478,6 +1624,10 @@ attribute-sets:
14781624
-
14791625
name: start-context
14801626
type: u32
1627+
-
1628+
name: flow-hash
1629+
type: nest
1630+
nested-attributes: flow
14811631
-
14821632
name: plca
14831633
attr-cnt-name: __ethtool-a-plca-cnt
@@ -2307,6 +2457,7 @@ operations:
23072457
- indir
23082458
- hkey
23092459
- input-xfrm
2460+
- flow-hash
23102461
dump:
23112462
request:
23122463
attributes:

Documentation/networking/ethtool-netlink.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,14 +1969,15 @@ used to ignore context 0s and only dump additional contexts).
19691969

19701970
Kernel response contents:
19711971

1972-
===================================== ====== ==========================
1972+
===================================== ====== ===============================
19731973
``ETHTOOL_A_RSS_HEADER`` nested reply header
19741974
``ETHTOOL_A_RSS_CONTEXT`` u32 context number
19751975
``ETHTOOL_A_RSS_HFUNC`` u32 RSS hash func
19761976
``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes
19771977
``ETHTOOL_A_RSS_HKEY`` binary Hash key bytes
19781978
``ETHTOOL_A_RSS_INPUT_XFRM`` u32 RSS input data transformation
1979-
===================================== ====== ==========================
1979+
``ETHTOOL_A_RSS_FLOW_HASH`` nested Header fields included in hash
1980+
===================================== ====== ===============================
19801981

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

19891992
PLCA_GET_CFG
19901993
============
@@ -2436,7 +2439,7 @@ are netlink only.
24362439
``ETHTOOL_SFLAGS`` ``ETHTOOL_MSG_FEATURES_SET``
24372440
``ETHTOOL_GPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_GET``
24382441
``ETHTOOL_SPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_SET``
2439-
``ETHTOOL_GRXFH`` n/a
2442+
``ETHTOOL_GRXFH`` ``ETHTOOL_MSG_RSS_GET``
24402443
``ETHTOOL_SRXFH`` n/a
24412444
``ETHTOOL_GGRO`` ``ETHTOOL_MSG_FEATURES_GET``
24422445
``ETHTOOL_SGRO`` ``ETHTOOL_MSG_FEATURES_SET``

include/uapi/linux/ethtool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ enum {
23142314
IPV6_USER_FLOW = 0x0e, /* spec only (usr_ip6_spec; nfc only) */
23152315
IPV4_FLOW = 0x10, /* hash only */
23162316
IPV6_FLOW = 0x11, /* hash only */
2317-
ETHER_FLOW = 0x12, /* spec only (ether_spec) */
2317+
ETHER_FLOW = 0x12, /* hash or spec (ether_spec) */
23182318

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

2374-
/* L3-L4 network traffic flow hash options */
2374+
/* L2-L4 network traffic flow hash options */
23752375
#define RXH_L2DA (1 << 1)
23762376
#define RXH_VLAN (1 << 2)
23772377
#define RXH_L3_PROTO (1 << 3)

include/uapi/linux/ethtool_netlink_generated.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,39 @@ enum {
678678
ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
679679
};
680680

681+
enum {
682+
ETHTOOL_A_FLOW_ETHER = 1,
683+
ETHTOOL_A_FLOW_IP4,
684+
ETHTOOL_A_FLOW_IP6,
685+
ETHTOOL_A_FLOW_TCP4,
686+
ETHTOOL_A_FLOW_TCP6,
687+
ETHTOOL_A_FLOW_UDP4,
688+
ETHTOOL_A_FLOW_UDP6,
689+
ETHTOOL_A_FLOW_SCTP4,
690+
ETHTOOL_A_FLOW_SCTP6,
691+
ETHTOOL_A_FLOW_AH4,
692+
ETHTOOL_A_FLOW_AH6,
693+
ETHTOOL_A_FLOW_ESP4,
694+
ETHTOOL_A_FLOW_ESP6,
695+
ETHTOOL_A_FLOW_AH_ESP4,
696+
ETHTOOL_A_FLOW_AH_ESP6,
697+
ETHTOOL_A_FLOW_GTPU4,
698+
ETHTOOL_A_FLOW_GTPU6,
699+
ETHTOOL_A_FLOW_GTPC4,
700+
ETHTOOL_A_FLOW_GTPC6,
701+
ETHTOOL_A_FLOW_GTPC_TEID4,
702+
ETHTOOL_A_FLOW_GTPC_TEID6,
703+
ETHTOOL_A_FLOW_GTPU_EH4,
704+
ETHTOOL_A_FLOW_GTPU_EH6,
705+
ETHTOOL_A_FLOW_GTPU_UL4,
706+
ETHTOOL_A_FLOW_GTPU_UL6,
707+
ETHTOOL_A_FLOW_GTPU_DL4,
708+
ETHTOOL_A_FLOW_GTPU_DL6,
709+
710+
__ETHTOOL_A_FLOW_CNT,
711+
ETHTOOL_A_FLOW_MAX = (__ETHTOOL_A_FLOW_CNT - 1)
712+
};
713+
681714
enum {
682715
ETHTOOL_A_RSS_UNSPEC,
683716
ETHTOOL_A_RSS_HEADER,
@@ -687,6 +720,7 @@ enum {
687720
ETHTOOL_A_RSS_HKEY,
688721
ETHTOOL_A_RSS_INPUT_XFRM,
689722
ETHTOOL_A_RSS_START_CONTEXT,
723+
ETHTOOL_A_RSS_FLOW_HASH,
690724

691725
__ETHTOOL_A_RSS_CNT,
692726
ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1)

net/ethtool/ioctl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ static int ethtool_rxnfc_copy_to_user(void __user *useraddr,
981981
static bool flow_type_hashable(u32 flow_type)
982982
{
983983
switch (flow_type) {
984+
case ETHER_FLOW:
984985
case TCP_V4_FLOW:
985986
case UDP_V4_FLOW:
986987
case SCTP_V4_FLOW:
@@ -1100,7 +1101,11 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
11001101
rc = ops->set_rxfh_fields(dev, &fields, NULL);
11011102
exit_unlock:
11021103
mutex_unlock(&dev->ethtool->rss_lock);
1103-
return rc;
1104+
if (rc)
1105+
return rc;
1106+
1107+
ethtool_rss_notify(dev, fields.rss_context);
1108+
return 0;
11041109
}
11051110

11061111
static noinline_for_stack int

0 commit comments

Comments
 (0)