tools/testing/selftests/drivers/net/psp.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/psp.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/psp.py- Extension
.py- Size
- 33998 bytes
- Lines
- 1008
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
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
"""Test suite for PSP capable drivers."""
import errno
import fcntl
import os
import socket
import struct
import termios
import time
from lib.py import defer
from lib.py import ksft_run, ksft_exit, ksft_pr
from lib.py import ksft_true, ksft_eq, ksft_ne, ksft_gt, ksft_raises
from lib.py import ksft_not_none
from lib.py import ksft_variants, KsftNamedVariant
from lib.py import KsftSkipEx, KsftFailEx
from lib.py import NetDrvEpEnv, NetDrvContEnv
from lib.py import Netlink, NlError, PSPFamily, RtnlFamily
from lib.py import NetNSEnter
from lib.py import bkg, rand_port, wait_port_listen
from lib.py import ip
def _get_outq(s):
one = b'\0' * 4
outq = fcntl.ioctl(s.fileno(), termios.TIOCOUTQ, one)
return struct.unpack("I", outq)[0]
def _send_with_ack(cfg, msg):
cfg.comm_sock.send(msg)
response = cfg.comm_sock.recv(4)
if response != b'ack\0':
raise RuntimeError("Unexpected server response", response)
def _remote_read_len(cfg):
cfg.comm_sock.send(b'read len\0')
return int(cfg.comm_sock.recv(1024)[:-1].decode('utf-8'))
def _make_clr_conn(cfg, ipver=None):
_send_with_ack(cfg, b'conn clr\0')
remote_addr = cfg.remote_addr_v[ipver] if ipver else cfg.remote_addr
s = socket.create_connection((remote_addr, cfg.comm_port), )
return s
def _make_psp_conn(cfg, version=0, ipver=None):
_send_with_ack(cfg, b'conn psp\0' + struct.pack('BB', version, version))
remote_addr = cfg.remote_addr_v[ipver] if ipver else cfg.remote_addr
s = socket.create_connection((remote_addr, cfg.comm_port), )
return s
def _close_conn(cfg, s):
_send_with_ack(cfg, b'data close\0')
s.close()
def _close_psp_conn(cfg, s):
_close_conn(cfg, s)
def _spi_xchg(s, rx):
s.send(struct.pack('I', rx['spi']) + rx['key'])
tx = s.recv(4 + len(rx['key']))
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.