tools/testing/selftests/drivers/net/hw/gro_hw.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/hw/gro_hw.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/hw/gro_hw.py- Extension
.py- Size
- 10164 bytes
- Lines
- 305
- 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
"""
HW GRO tests focusing on device machinery like stats, rather than protocol
processing.
"""
import glob
import re
from lib.py import ksft_run, ksft_exit, ksft_pr
from lib.py import ksft_eq, ksft_ge, ksft_variants
from lib.py import NetDrvEpEnv, NetdevFamily
from lib.py import KsftSkipEx
from lib.py import bkg, cmd, defer, ethtool, ip
# gro.c uses hardcoded DPORT=8000
GRO_DPORT = 8000
def _get_queue_stats(cfg, queue_id):
"""Get stats for a specific Rx queue."""
cfg.wait_hw_stats_settle()
data = cfg.netnl.qstats_get({"ifindex": cfg.ifindex, "scope": ["queue"]},
dump=True)
for q in data:
if q.get('queue-type') == 'rx' and q.get('queue-id') == queue_id:
return q
return {}
def _resolve_dmac(cfg, ipver):
"""Find the destination MAC address for sending packets."""
attr = "dmac" + ipver
if hasattr(cfg, attr):
return getattr(cfg, attr)
route = ip(f"-{ipver} route get {cfg.addr_v[ipver]}",
json=True, host=cfg.remote)[0]
gw = route.get("gateway")
if not gw:
setattr(cfg, attr, cfg.dev['address'])
return getattr(cfg, attr)
cmd(f"ping -c1 -W0 -I{cfg.remote_ifname} {gw}", host=cfg.remote)
neigh = ip(f"neigh get {gw} dev {cfg.remote_ifname}",
json=True, host=cfg.remote)[0]
setattr(cfg, attr, neigh['lladdr'])
return getattr(cfg, attr)
def _require_ntuple(cfg):
features = ethtool(f"-k {cfg.ifname}", json=True)[0]
if not features["ntuple-filters"]["active"]:
if features["ntuple-filters"]["fixed"]:
raise KsftSkipEx("Device does not support ntuple-filters")
ethtool(f"-K {cfg.ifname} ntuple-filters on")
defer(ethtool, f"-K {cfg.ifname} ntuple-filters off")
def _setup_isolated_queue(cfg):
"""Set up an isolated queue for testing using ntuple filter.
Remove queue 1 from the default RSS context and steer test traffic to it.
"""
_require_ntuple(cfg)
test_queue = 1
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.