tools/testing/selftests/drivers/net/psp_responder.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/drivers/net/psp_responder.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/drivers/net/psp_responder.c- Extension
.c- Size
- 9670 bytes
- Lines
- 480
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
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
stdio.hstring.hsys/poll.hsys/socket.hsys/time.hnetinet/in.hunistd.hynl.hpsp-user.h
Detected Declarations
struct optsenum accept_cfgfunction conn_setup_pspfunction send_ackfunction send_errfunction send_strfunction run_sessionfunction spawn_serverfunction run_responderfunction usagefunction parse_cmd_optsfunction psp_dev_set_enafunction mainfunction ynl_dump_foreach
Annotated Snippet
struct opts {
int port;
int ifindex;
bool verbose;
};
enum accept_cfg {
ACCEPT_CFG_NONE = 0,
ACCEPT_CFG_CLEAR,
ACCEPT_CFG_PSP,
};
static struct {
unsigned char tx;
unsigned char rx;
} psp_vers;
static int conn_setup_psp(struct ynl_sock *ys, struct opts *opts, int data_sock)
{
struct psp_rx_assoc_rsp *rsp;
struct psp_rx_assoc_req *req;
struct psp_tx_assoc_rsp *tsp;
struct psp_tx_assoc_req *teq;
char info[300];
int key_len;
ssize_t sz;
__u32 spi;
dbg("create PSP connection\n");
// Rx assoc alloc
req = psp_rx_assoc_req_alloc();
psp_rx_assoc_req_set_sock_fd(req, data_sock);
psp_rx_assoc_req_set_version(req, psp_vers.rx);
rsp = psp_rx_assoc(ys, req);
psp_rx_assoc_req_free(req);
if (!rsp) {
perror("ERROR: failed to Rx assoc");
return -1;
}
// SPI exchange
key_len = rsp->rx_key._len.key;
memcpy(info, &rsp->rx_key.spi, sizeof(spi));
memcpy(&info[sizeof(spi)], rsp->rx_key.key, key_len);
sz = sizeof(spi) + key_len;
send(data_sock, info, sz, MSG_WAITALL);
psp_rx_assoc_rsp_free(rsp);
sz = recv(data_sock, info, sz, MSG_WAITALL);
if (sz < 0) {
perror("ERROR: failed to read PSP key from sock");
return -1;
}
memcpy(&spi, info, sizeof(spi));
// Setup Tx assoc
teq = psp_tx_assoc_req_alloc();
psp_tx_assoc_req_set_sock_fd(teq, data_sock);
psp_tx_assoc_req_set_version(teq, psp_vers.tx);
psp_tx_assoc_req_set_tx_key_spi(teq, spi);
psp_tx_assoc_req_set_tx_key_key(teq, &info[sizeof(spi)], key_len);
tsp = psp_tx_assoc(ys, teq);
psp_tx_assoc_req_free(teq);
if (!tsp) {
perror("ERROR: failed to Tx assoc");
return -1;
}
psp_tx_assoc_rsp_free(tsp);
return 0;
}
static void send_ack(int sock)
{
send(sock, "ack", 4, MSG_WAITALL);
}
static void send_err(int sock)
{
send(sock, "err", 4, MSG_WAITALL);
}
static void send_str(int sock, int value)
Annotation
- Immediate include surface: `stdio.h`, `string.h`, `sys/poll.h`, `sys/socket.h`, `sys/time.h`, `netinet/in.h`, `unistd.h`, `ynl.h`.
- Detected declarations: `struct opts`, `enum accept_cfg`, `function conn_setup_psp`, `function send_ack`, `function send_err`, `function send_str`, `function run_session`, `function spawn_server`, `function run_responder`, `function usage`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.