amd-xgbe: add RSS ethtool self-test
Subsystems (3)
Raju Rangoju
maintainerPATCH v3 4/4 amd-xgbe: add RSS ethtool self-test
Add a Receive Side Scaling (RSS) self-test to the ethtool diagnostic suite to verify that the hardware correctly computes hash values for incoming packets.
The test validates RSS functionality by:
1. Checking for RSS hardware feature support (rss bit in MAC_HWF1R)
2. Sending a test packet with specific TCP/UDP ports to trigger hash computation
3. Verifying that the received packet has a non-zero hash value computed by the hardware
The test uses the existing loopback infrastructure and requires PHY loopback mode. It uses specific port values (sport=0xabc, dport=0xdef) to generate a deterministic hash that exercises the RSS hash computation logic.
This test helps users verify that RSS is properly configured and functioning, which is essential for multi-queue performance on multi-core systems.
Usage:
$ ethtool -t <interface>
--- drivers/net/ethernet/amd/xgbe/xgbe-selftest.c | 32 +++++++++++++++++++ include/net/selftests.h | 1 + 2 files changed, 33 insertions(+)
drivers/net/ethernet/amd/xgbe/xgbe-selftest.c +32 -0
@@ -214,8 +214,13 @@ static int xgbe_test_loopback_validate(struct sk_buff *skb,if (tdata->packet->id != hdr->id) goto out; +/* Validate RSS hash if expected */ +if (tdata->packet->exp_hash && !skb->hash) + goto out; + tdata->ok = true;complete (&tdata->comp); + out:kfree_skb (skb);return 0 ;
@@ -268,6 +273,29 @@ static int __xgbe_test_loopback(struct xgbe_prv_data *pdata,return ret; } +static int xgbe_test_rss (struct xgbe_prv_data *pdata) +{ +struct net_packet_attrs attr = {}; +int ret; + +/* Check for RSS hardware support */ +if (!pdata->hw_feat.rss) +return -EOPNOTSUPP ; + + attr.dst = pdata->netdev->dev_addr; +/* +* Use specific port values to generate a hash. +* The asymmetric port values ensure the hash computation +* produces a non-zero result for test validation. +*/ + attr.sport =0xabc ; + attr.dport =0xdef ; + attr.exp_hash = true; + ret =__xgbe_test_loopback (pdata, &attr); + +return ret; +} +static int xgbe_test_mac_loopback (struct xgbe_prv_data *pdata) {struct net_packet_attrs attr = {};
@@ -371,6 +399,10 @@ static const struct xgbe_test xgbe_selftests[] = { .name = "ARP Offload ", .lb = XGBE_LOOPBACK_PHY, .fn = xgbe_test_arpoffload, + }, { + .name = "RSS ", + .lb = XGBE_LOOPBACK_PHY, + .fn = xgbe_test_rss, } };
include/net/selftests.h +1 -0
@@ -19,6 +19,7 @@ struct net_packet_attrs {u8 id;u16 queue_mapping;bool bad_csum; +u32 exp_hash; };struct net_test_priv {
Signature · 1 line
2.34.1