drivers/firewire/packet-serdes-test.c

Source file repositories/reference/linux-study-clean/drivers/firewire/packet-serdes-test.c

File Facts

System
Linux kernel
Corpus path
drivers/firewire/packet-serdes-test.c
Extension
.c
Size
32847 bytes
Lines
918
Domain
Driver Families
Bucket
drivers/firewire
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-or-later
//
// packet-serdes-test.c - An application of Kunit to check serialization/deserialization of packets
//			  defined by IEEE 1394.
//
// Copyright (c) 2024 Takashi Sakamoto

#include <kunit/test.h>

#include <linux/firewire-constants.h>

#include "packet-header-definitions.h"
#include "phy-packet-definitions.h"

static void serialize_async_header_common(u32 header[ASYNC_HEADER_QUADLET_COUNT],
					  unsigned int dst_id, unsigned int tlabel,
					  unsigned int retry, unsigned int tcode,
					  unsigned int priority, unsigned int src_id)
{
	async_header_set_destination(header, dst_id);
	async_header_set_tlabel(header, tlabel);
	async_header_set_retry(header, retry);
	async_header_set_tcode(header, tcode);
	async_header_set_priority(header, priority);
	async_header_set_source(header, src_id);
}

static void serialize_async_header_request(u32 header[ASYNC_HEADER_QUADLET_COUNT],
					   unsigned int dst_id, unsigned int tlabel,
					   unsigned int retry, unsigned int tcode,
					   unsigned int priority, unsigned int src_id, u64 offset)
{
	serialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id);
	async_header_set_offset(header, offset);
}

static void serialize_async_header_quadlet_request(u32 header[ASYNC_HEADER_QUADLET_COUNT],
						   unsigned int dst_id, unsigned int tlabel,
						   unsigned int retry, unsigned int tcode,
						   unsigned int priority, unsigned int src_id,
						   u64 offset)
{
	serialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id,
				       offset);
}

static void serialize_async_header_block_request(u32 header[ASYNC_HEADER_QUADLET_COUNT],
						 unsigned int dst_id, unsigned int tlabel,
						 unsigned int retry, unsigned int tcode,
						 unsigned int priority, unsigned int src_id,
						 u64 offset, unsigned int data_length,
						 unsigned int extended_tcode)
{
	serialize_async_header_request(header, dst_id, tlabel, retry, tcode, priority, src_id,
				       offset);
	async_header_set_data_length(header, data_length);
	async_header_set_extended_tcode(header, extended_tcode);
}

static void serialize_async_header_response(u32 header[ASYNC_HEADER_QUADLET_COUNT],
					    unsigned int dst_id, unsigned int tlabel,
					    unsigned int retry, unsigned int tcode,
					    unsigned int priority, unsigned int src_id,
					    unsigned int rcode)
{
	serialize_async_header_common(header, dst_id, tlabel, retry, tcode, priority, src_id);
	async_header_set_rcode(header, rcode);
}

static void serialize_async_header_quadlet_response(u32 header[ASYNC_HEADER_QUADLET_COUNT],
						    unsigned int dst_id, unsigned int tlabel,
						    unsigned int retry, unsigned int tcode,
						    unsigned int priority, unsigned int src_id,
						    unsigned int rcode)
{
	serialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id,
					rcode);
}

static void serialize_async_header_block_response(u32 header[ASYNC_HEADER_QUADLET_COUNT],
						  unsigned int dst_id, unsigned int tlabel,
						  unsigned int retry, unsigned int tcode,
						  unsigned int priority, unsigned int src_id,
						  unsigned int rcode, unsigned int data_length,
						  unsigned int extended_tcode)
{
	serialize_async_header_response(header, dst_id, tlabel, retry, tcode, priority, src_id,
					rcode);
	async_header_set_data_length(header, data_length);
	async_header_set_extended_tcode(header, extended_tcode);

Annotation

Implementation Notes