1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2020 Linaro Ltd.
6 #ifndef _GSI_PRIVATE_H_
7 #define _GSI_PRIVATE_H_
9 /* === Only "gsi.c" and "gsi_trans.c" should include this file === */
11 #include <linux/types.h>
17 #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */
19 /* Return the entry that follows one provided in a transaction pool */
20 void *gsi_trans_pool_next(struct gsi_trans_pool *pool, void *element);
23 * gsi_trans_move_complete() - Mark a GSI transaction completed
24 * @trans: Transaction to commit
26 void gsi_trans_move_complete(struct gsi_trans *trans);
29 * gsi_trans_move_polled() - Mark a transaction polled
30 * @trans: Transaction to update
32 void gsi_trans_move_polled(struct gsi_trans *trans);
35 * gsi_trans_complete() - Complete a GSI transaction
36 * @trans: Transaction to complete
38 * Marks a transaction complete (including freeing it).
40 void gsi_trans_complete(struct gsi_trans *trans);
43 * gsi_channel_trans_mapped() - Return a transaction mapped to a TRE index
44 * @channel: Channel associated with the transaction
45 * @index: Index of the TRE having a transaction
47 * Return: The GSI transaction pointer associated with the TRE index
49 struct gsi_trans *gsi_channel_trans_mapped(struct gsi_channel *channel,
53 * gsi_channel_trans_complete() - Return a channel's next completed transaction
54 * @channel: Channel whose next transaction is to be returned
56 * Return: The next completed transaction, or NULL if nothing new
58 struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel);
61 * gsi_channel_trans_cancel_pending() - Cancel pending transactions
62 * @channel: Channel whose pending transactions should be cancelled
64 * Cancel all pending transactions on a channel. These are transactions
65 * that have been committed but not yet completed. This is required when
66 * the channel gets reset. At that time all pending transactions will be
67 * marked as cancelled.
69 * NOTE: Transactions already complete at the time of this call are
72 void gsi_channel_trans_cancel_pending(struct gsi_channel *channel);
75 * gsi_channel_trans_init() - Initialize a channel's GSI transaction info
77 * @channel_id: Channel number
79 * Return: 0 if successful, or -ENOMEM on allocation failure
81 * Creates and sets up information for managing transactions on a channel
83 int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id);
86 * gsi_channel_trans_exit() - Inverse of gsi_channel_trans_init()
87 * @channel: Channel whose transaction information is to be cleaned up
89 void gsi_channel_trans_exit(struct gsi_channel *channel);
92 * gsi_channel_doorbell() - Ring a channel's doorbell
93 * @channel: Channel whose doorbell should be rung
95 * Rings a channel's doorbell to inform the GSI hardware that new
96 * transactions (TREs, really) are available for it to process.
98 void gsi_channel_doorbell(struct gsi_channel *channel);
101 * gsi_ring_virt() - Return virtual address for a ring entry
102 * @ring: Ring whose address is to be translated
103 * @addr: Index (slot number) of entry
105 void *gsi_ring_virt(struct gsi_ring *ring, u32 index);
108 * gsi_channel_tx_queued() - Report the number of bytes queued to hardware
109 * @channel: Channel whose bytes have been queued
111 * This arranges for the the number of transactions and bytes for
112 * transfer that have been queued to hardware to be reported. It
113 * passes this information up the network stack so it can be used to
114 * throttle transmissions.
116 void gsi_channel_tx_queued(struct gsi_channel *channel);
118 #endif /* _GSI_PRIVATE_H_ */