Skip to content

Commit 1783317

Browse files
committed
ethtool: rss: report which fields are configured for hashing
Implement ETHTOOL_GRXFH over Netlink. The number of flow types is reasonable (around 20) so report all of them at once for simplicity. Do not maintain the flow ID mapping with ioctl at the uAPI level. This gives us a chance to clean up the confusion that come from RxNFC vs RxFH (flow direction vs hashing) in the ioctl. Try to align with the names used in ethtool CLI, they seem to have stood the test of time just fine. One annoyance is that we still call L4 ports the weird names, but I guess they also apply to IPSec (where they cover the SPI) so it is what it is. $ 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-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent d797469 commit 1783317

File tree

5 files changed

+291
-14
lines changed

5 files changed

+291
-14
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_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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,11 @@ ethtool_set_rxfh_fields(struct net_device *dev, u32 cmd, void __user *useraddr)
11011101
rc = ops->set_rxfh_fields(dev, &fields, NULL);
11021102
exit_unlock:
11031103
mutex_unlock(&dev->ethtool->rss_lock);
1104-
return rc;
1104+
if (rc)
1105+
return rc;
1106+
1107+
ethtool_rss_notify(dev, fields.rss_context);
1108+
return 0;
11051109
}
11061110

11071111
static noinline_for_stack int

0 commit comments

Comments
 (0)