drivers/platform/surface/aggregator/ssh_packet_layer.h

Source file repositories/reference/linux-study-clean/drivers/platform/surface/aggregator/ssh_packet_layer.h

File Facts

System
Linux kernel
Corpus path
drivers/platform/surface/aggregator/ssh_packet_layer.h
Extension
.h
Size
6093 bytes
Lines
191
Domain
Driver Families
Bucket
drivers/platform
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

struct ssh_ptl_ops {
	void (*data_received)(struct ssh_ptl *p, const struct ssam_span *data);
};

/**
 * struct ssh_ptl - SSH packet transport layer.
 * @serdev:        Serial device providing the underlying data transport.
 * @state:         State(-flags) of the transport layer.
 * @queue:         Packet submission queue.
 * @queue.lock:    Lock for modifying the packet submission queue.
 * @queue.head:    List-head of the packet submission queue.
 * @pending:       Set/list of pending packets.
 * @pending.lock:  Lock for modifying the pending set.
 * @pending.head:  List-head of the pending set/list.
 * @pending.count: Number of currently pending packets.
 * @tx:            Transmitter subsystem.
 * @tx.running:    Flag indicating (desired) transmitter thread state.
 * @tx.thread:     Transmitter thread.
 * @tx.thread_cplt_tx:  Completion for transmitter thread waiting on transfer.
 * @tx.thread_cplt_pkt: Completion for transmitter thread waiting on packets.
 * @tx.packet_wq:  Waitqueue-head for packet transmit completion.
 * @rx:            Receiver subsystem.
 * @rx.thread:     Receiver thread.
 * @rx.wq:         Waitqueue-head for receiver thread.
 * @rx.fifo:       Buffer for receiving data/pushing data to receiver thread.
 * @rx.buf:        Buffer for evaluating data on receiver thread.
 * @rx.blocked:    List of recent/blocked sequence IDs to detect retransmission.
 * @rx.blocked.seqs:   Array of blocked sequence IDs.
 * @rx.blocked.offset: Offset indicating where a new ID should be inserted.
 * @rtx_timeout:   Retransmission timeout subsystem.
 * @rtx_timeout.lock:    Lock for modifying the retransmission timeout reaper.
 * @rtx_timeout.timeout: Timeout interval for retransmission.
 * @rtx_timeout.expires: Time specifying when the reaper work is next scheduled.
 * @rtx_timeout.reaper:  Work performing timeout checks and subsequent actions.
 * @ops:           Packet layer operations.
 */
struct ssh_ptl {
	struct serdev_device *serdev;
	unsigned long state;

	struct {
		spinlock_t lock;
		struct list_head head;
	} queue;

	struct {
		spinlock_t lock;
		struct list_head head;
		atomic_t count;
	} pending;

	struct {
		atomic_t running;
		struct task_struct *thread;
		struct completion thread_cplt_tx;
		struct completion thread_cplt_pkt;
		struct wait_queue_head packet_wq;
	} tx;

	struct {
		struct task_struct *thread;
		struct wait_queue_head wq;
		struct kfifo fifo;
		struct sshp_buf buf;

		struct {
			u16 seqs[8];
			u16 offset;
		} blocked;
	} rx;

	struct {
		spinlock_t lock;
		ktime_t timeout;
		ktime_t expires;
		struct delayed_work reaper;
	} rtx_timeout;

	struct ssh_ptl_ops ops;
};

#define __ssam_prcond(func, p, fmt, ...)		\
	do {						\
		typeof(p) __p = (p);			\
							\
		if (__p)				\
			func(__p, fmt, ##__VA_ARGS__);	\
	} while (0)

#define ptl_dbg(p, fmt, ...)  dev_dbg(&(p)->serdev->dev, fmt, ##__VA_ARGS__)

Annotation

Implementation Notes