tools/testing/selftests/drivers/net/hds.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/hds.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/hds.py- Extension
.py- Size
- 11565 bytes
- Lines
- 330
- 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
import errno
import os
import random
from typing import Union
from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_raises, KsftSkipEx
from lib.py import CmdExitFailure, EthtoolFamily, NlError
from lib.py import NetDrvEnv
from lib.py import defer, ethtool, ip
def _get_hds_mode(cfg, netnl) -> str:
try:
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
except NlError as e:
raise KsftSkipEx('ring-get not supported by device')
if 'tcp-data-split' not in rings:
raise KsftSkipEx('tcp-data-split not supported by device')
return rings['tcp-data-split']
def _xdp_onoff(cfg):
prog = cfg.net_lib_dir / "xdp_dummy.bpf.o"
ip("link set dev %s xdp obj %s sec xdp" %
(cfg.ifname, prog))
ip("link set dev %s xdp off" % cfg.ifname)
def _ioctl_ringparam_modify(cfg, netnl) -> None:
"""
Helper for performing a hopefully unimportant IOCTL SET.
IOCTL does not support HDS, so it should not affect the HDS config.
"""
try:
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
except NlError as e:
raise KsftSkipEx('ring-get not supported by device')
if 'tx' not in rings:
raise KsftSkipEx('setting Tx ring size not supported')
try:
ethtool(f"--disable-netlink -G {cfg.ifname} tx {rings['tx'] // 2}")
except CmdExitFailure as e:
ethtool(f"--disable-netlink -G {cfg.ifname} tx {rings['tx'] * 2}")
defer(ethtool, f"-G {cfg.ifname} tx {rings['tx']}")
def get_hds(cfg, netnl) -> None:
_get_hds_mode(cfg, netnl)
def get_hds_thresh(cfg, netnl) -> None:
try:
rings = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
except NlError as e:
raise KsftSkipEx('ring-get not supported by device')
if 'hds-thresh' not in rings:
raise KsftSkipEx('hds-thresh not supported by device')
def _hds_reset(cfg, netnl, rings) -> None:
cur = netnl.rings_get({'header': {'dev-index': cfg.ifindex}})
arg = {'header': {'dev-index': cfg.ifindex}}
if cur.get('tcp-data-split') != rings.get('tcp-data-split'):
# Try to reset to "unknown" first, we don't know if the setting
# was the default or user chose it. Default seems more likely.
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.