Commit | Line | Data |
---|---|---|
ca48b27b AE |
1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | ||
3 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. | |
81186959 | 4 | * Copyright (C) 2018-2024 Linaro Ltd. |
ca48b27b AE |
5 | */ |
6 | #ifndef _GSI_PRIVATE_H_ | |
7 | #define _GSI_PRIVATE_H_ | |
8 | ||
9 | /* === Only "gsi.c" and "gsi_trans.c" should include this file === */ | |
10 | ||
11 | #include <linux/types.h> | |
12 | ||
81186959 | 13 | struct gsi; |
ca48b27b | 14 | struct gsi_channel; |
81186959 AE |
15 | struct gsi_ring; |
16 | struct gsi_trans; | |
ca48b27b | 17 | |
19aaf72c | 18 | #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ |
ca48b27b | 19 | |
ca48b27b AE |
20 | /** |
21 | * gsi_trans_move_complete() - Mark a GSI transaction completed | |
ace5dc61 | 22 | * @trans: Transaction whose state is to be updated |
ca48b27b AE |
23 | */ |
24 | void gsi_trans_move_complete(struct gsi_trans *trans); | |
25 | ||
26 | /** | |
27 | * gsi_trans_move_polled() - Mark a transaction polled | |
ace5dc61 | 28 | * @trans: Transaction whose state is to be updated |
ca48b27b AE |
29 | */ |
30 | void gsi_trans_move_polled(struct gsi_trans *trans); | |
31 | ||
32 | /** | |
33 | * gsi_trans_complete() - Complete a GSI transaction | |
34 | * @trans: Transaction to complete | |
35 | * | |
36 | * Marks a transaction complete (including freeing it). | |
37 | */ | |
38 | void gsi_trans_complete(struct gsi_trans *trans); | |
39 | ||
40 | /** | |
41 | * gsi_channel_trans_mapped() - Return a transaction mapped to a TRE index | |
42 | * @channel: Channel associated with the transaction | |
43 | * @index: Index of the TRE having a transaction | |
44 | * | |
e3eea08e | 45 | * Return: The GSI transaction pointer associated with the TRE index |
ca48b27b AE |
46 | */ |
47 | struct gsi_trans *gsi_channel_trans_mapped(struct gsi_channel *channel, | |
48 | u32 index); | |
49 | ||
50 | /** | |
51 | * gsi_channel_trans_complete() - Return a channel's next completed transaction | |
52 | * @channel: Channel whose next transaction is to be returned | |
53 | * | |
e3eea08e | 54 | * Return: The next completed transaction, or NULL if nothing new |
ca48b27b AE |
55 | */ |
56 | struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel); | |
57 | ||
58 | /** | |
59 | * gsi_channel_trans_cancel_pending() - Cancel pending transactions | |
60 | * @channel: Channel whose pending transactions should be cancelled | |
61 | * | |
62 | * Cancel all pending transactions on a channel. These are transactions | |
63 | * that have been committed but not yet completed. This is required when | |
64 | * the channel gets reset. At that time all pending transactions will be | |
65 | * marked as cancelled. | |
66 | * | |
67 | * NOTE: Transactions already complete at the time of this call are | |
68 | * unaffected. | |
69 | */ | |
70 | void gsi_channel_trans_cancel_pending(struct gsi_channel *channel); | |
71 | ||
72 | /** | |
73 | * gsi_channel_trans_init() - Initialize a channel's GSI transaction info | |
74 | * @gsi: GSI pointer | |
75 | * @channel_id: Channel number | |
76 | * | |
e3eea08e | 77 | * Return: 0 if successful, or -ENOMEM on allocation failure |
ca48b27b AE |
78 | * |
79 | * Creates and sets up information for managing transactions on a channel | |
80 | */ | |
81 | int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id); | |
82 | ||
83 | /** | |
84 | * gsi_channel_trans_exit() - Inverse of gsi_channel_trans_init() | |
85 | * @channel: Channel whose transaction information is to be cleaned up | |
86 | */ | |
87 | void gsi_channel_trans_exit(struct gsi_channel *channel); | |
88 | ||
89 | /** | |
90 | * gsi_channel_doorbell() - Ring a channel's doorbell | |
91 | * @channel: Channel whose doorbell should be rung | |
92 | * | |
93 | * Rings a channel's doorbell to inform the GSI hardware that new | |
94 | * transactions (TREs, really) are available for it to process. | |
95 | */ | |
96 | void gsi_channel_doorbell(struct gsi_channel *channel); | |
97 | ||
e0e3406c | 98 | /* gsi_channel_update() - Update knowledge of channel hardware state |
019e37ea | 99 | * @channel: Channel to be updated |
e0e3406c | 100 | * |
ace5dc61 AE |
101 | * Consult hardware, change the state of any newly-completed transactions |
102 | * on a channel. | |
e0e3406c | 103 | */ |
019e37ea | 104 | void gsi_channel_update(struct gsi_channel *channel); |
e0e3406c | 105 | |
ca48b27b AE |
106 | /** |
107 | * gsi_ring_virt() - Return virtual address for a ring entry | |
108 | * @ring: Ring whose address is to be translated | |
862d3f2c | 109 | * @index: Index (slot number) of entry |
ca48b27b AE |
110 | */ |
111 | void *gsi_ring_virt(struct gsi_ring *ring, u32 index); | |
112 | ||
4e0f28e9 AE |
113 | /** |
114 | * gsi_trans_tx_committed() - Record bytes committed for transmit | |
115 | * @trans: TX endpoint transaction being committed | |
116 | * | |
117 | * Report that a TX transaction has been committed. It updates some | |
118 | * statistics used to manage transmit rates. | |
119 | */ | |
120 | void gsi_trans_tx_committed(struct gsi_trans *trans); | |
121 | ||
ca48b27b | 122 | /** |
bcec9ecb AE |
123 | * gsi_trans_tx_queued() - Report a queued TX channel transaction |
124 | * @trans: Transaction being passed to hardware | |
ca48b27b | 125 | * |
bcec9ecb AE |
126 | * Report to the network stack that a TX transaction is being supplied |
127 | * to the hardware. | |
ca48b27b | 128 | */ |
bcec9ecb | 129 | void gsi_trans_tx_queued(struct gsi_trans *trans); |
ca48b27b AE |
130 | |
131 | #endif /* _GSI_PRIVATE_H_ */ |