tools/testing/selftests/drivers/net/hw/rss_drv.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/hw/rss_drv.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/hw/rss_drv.py- Extension
.py- Size
- 10849 bytes
- Lines
- 314
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
"""
Driver-related behavior tests for RSS.
"""
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_ge
from lib.py import ksft_variants, KsftNamedVariant, KsftSkipEx, ksft_raises
from lib.py import defer, ethtool, CmdExitFailure
from lib.py import EthtoolFamily, NlError
from lib.py import NetDrvEnv
def _is_power_of_two(n):
return n > 0 and (n & (n - 1)) == 0
def _get_rss(cfg, context=0):
return ethtool(f"-x {cfg.ifname} context {context}", json=True)[0]
def _test_rss_indir_size(cfg, qcnt, context=0):
"""Test that indirection table size is at least 4x queue count."""
ethtool(f"-L {cfg.ifname} combined {qcnt}")
rss = _get_rss(cfg, context=context)
indir = rss['rss-indirection-table']
ksft_ge(len(indir), 4 * qcnt, "Table smaller than 4x")
return len(indir)
def _maybe_create_context(cfg, create_context):
""" Either create a context and return its ID or return 0 for main ctx """
if not create_context:
return 0
try:
ctx = cfg.ethnl.rss_create_act({'header': {'dev-index': cfg.ifindex}})
ctx_id = ctx['context']
defer(cfg.ethnl.rss_delete_act,
{'header': {'dev-index': cfg.ifindex}, 'context': ctx_id})
except NlError:
raise KsftSkipEx("Device does not support additional RSS contexts")
return ctx_id
def _require_dynamic_indir_size(cfg, ch_max):
"""Skip if the device does not dynamically size its indirection table."""
ethtool(f"-X {cfg.ifname} default")
ethtool(f"-L {cfg.ifname} combined 2")
small = len(_get_rss(cfg)['rss-indirection-table'])
ethtool(f"-L {cfg.ifname} combined {ch_max}")
large = len(_get_rss(cfg)['rss-indirection-table'])
if small == large:
raise KsftSkipEx("Device does not dynamically size indirection table")
@ksft_variants([
KsftNamedVariant("main", False),
KsftNamedVariant("ctx", True),
])
def indir_size_4x(cfg, create_context):
"""
Test that the indirection table has at least 4 entries per queue.
Empirically network-heavy workloads like memcache suffer with the 33%
imbalance of a 2x indirection table size.
4x table translates to a 16% imbalance.
"""
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.