Hi!

Some NICs (e.g. bnxt) change their RSS indirection table size based on
the queue count, because the hardware table is a shared resource. The
ethtool core locks ctx->indir_size at context creation, so drivers
have to reject channel changes when RSS contexts exist.

This series adds resize helpers and wires them up in bnxt and
netdevsim.

Patch 1 adds three core helpers:
  ethtool_rxfh_indir_can_resize() - read-only validation
  ethtool_rxfh_indir_resize() - fold/unfold a raw table in place
  ethtool_rxfh_contexts_resize_all() - resize all non-default
    contexts (all-or-none), with locking and RSS_NTF notifications

Patch 2 uses them in bnxt_set_channels(), replacing the -EINVAL
rejection. Context 0 is validated first, then non-default contexts are
resized, then context 0 is mutated.

Patch 3 adds RSS context support to netdevsim with dynamic table
sizing (roundup_pow_of_two(channels) * 16), exercising the full resize
path.

Patches 4-5 add tests:
  ethtool-rss.sh - netdevsim-specific bash test
  rss_drv.py - Python test that runs on any device with dynamic
    table sizing (skips otherwise)

Running the tests:

  # netdevsim bash test (requires root, netdevsim module)
  cd tools/testing/selftests/drivers/net/netdevsim
  sudo ./ethtool-rss.sh

  # Python test on netdevsim
  cd tools/testing/selftests/drivers/net/hw
  sudo ./rss_drv.py

  # Python test on real hardware
  sudo NETIF=eth0 ./rss_drv.py

Open items:

 - Pre-existing bug in bnxt: the IFF_RXFH_CONFIGURED guard in
   bnxt_set_channels() only protects context 0. If context 0 uses
   defaults but non-default contexts exist, channel changes that
   change the table size succeed without updating ctx->indir_size for
   those contexts. The core's ethtool_check_max_channel() prevents
   invalid queue references but not the size mismatch itself. This
   series fixes it by resizing all contexts. Should a separate fix be
   sent to net for the existing bug?

 - No user-controlled minimum table size yet. The plan is to record
   the user-provided indirection table length in the context (e.g.
   ctx->user_indir_size) and use it as a floor when folding: reject if
   new_size < user_indir_size. This way the user's original table size
   serves as an implicit minimum, preventing the driver from shrinking
   below what the user intended. Left for a follow-up.

 - rss_drv.py lives in drivers/net/hw/ but runs on netdevsim too now.
   Maybe move up a level?


Björn Töpel (5):
  ethtool: Add RSS indirection table resize helpers
  bnxt_en: Resize RSS contexts on channel count change
  netdevsim: Add RSS context support with dynamic table sizing
  selftests: netdevsim: Add RSS indirection table resize test
  selftests: rss_drv: Add RSS indirection table resize tests

 .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c |  23 +++-
 drivers/net/netdevsim/ethtool.c               | 119 ++++++++++++++++-
 drivers/net/netdevsim/netdevsim.h             |   4 +
 include/linux/ethtool.h                       |   3 +
 net/ethtool/common.c                          | 126 ++++++++++++++++++
 .../selftests/drivers/net/hw/rss_drv.py       | 101 +++++++++++++-
 .../selftests/drivers/net/netdevsim/Makefile  |   1 +
 .../drivers/net/netdevsim/ethtool-rss.sh      | 123 +++++++++++++++++
 8 files changed, 488 insertions(+), 12 deletions(-)
 create mode 100755 tools/testing/selftests/drivers/net/netdevsim/ethtool-rss.sh


base-commit: ed0abfe93fd135dac223e87a3c945017b1fa8bfc
-- 
2.53.0


Reply via email to