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 Signed-off-by: Raju Rangoju --- drivers/net/ethernet/amd/xgbe/xgbe-selftest.c | 32 +++++++++++++++++++ include/net/selftests.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c b/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c index ae4825578c59..bd1c757bbc3f 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-selftest.c @@ -100,8 +100,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; @@ -154,6 +159,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_arp_validate(struct sk_buff *skb, struct net_device *ndev, struct packet_type *pt, @@ -368,6 +396,10 @@ static const struct xgbe_test xgbe_selftests[] = { .name = "ARP Offload ", .lb = XGBE_LOOPBACK_PHY, .fn = xgbe_test_arpoffload, + }, { + .name = "RSS Hash ", + .lb = XGBE_LOOPBACK_PHY, + .fn = xgbe_test_rss, }, }; diff --git a/include/net/selftests.h b/include/net/selftests.h index c36e07406ad4..18a9b4830dfc 100644 --- a/include/net/selftests.h +++ b/include/net/selftests.h @@ -19,6 +19,7 @@ struct net_packet_attrs { u8 id; u16 queue_mapping; bool bad_csum; + u32 exp_hash; }; struct net_test_priv { -- 2.34.1