xref: /openbmc/linux/drivers/net/ipa/gsi_private.h (revision 002dff36)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2018-2020 Linaro Ltd.
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 
13 struct gsi_trans;
14 struct gsi_ring;
15 struct gsi_channel;
16 
17 #define GSI_RING_ELEMENT_SIZE	16	/* bytes */
18 
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);
21 
22 /**
23  * gsi_trans_move_complete() - Mark a GSI transaction completed
24  * @trans:	Transaction to commit
25  */
26 void gsi_trans_move_complete(struct gsi_trans *trans);
27 
28 /**
29  * gsi_trans_move_polled() - Mark a transaction polled
30  * @trans:	Transaction to update
31  */
32 void gsi_trans_move_polled(struct gsi_trans *trans);
33 
34 /**
35  * gsi_trans_complete() - Complete a GSI transaction
36  * @trans:	Transaction to complete
37  *
38  * Marks a transaction complete (including freeing it).
39  */
40 void gsi_trans_complete(struct gsi_trans *trans);
41 
42 /**
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
46  *
47  * @Return:	The GSI transaction pointer associated with the TRE index
48  */
49 struct gsi_trans *gsi_channel_trans_mapped(struct gsi_channel *channel,
50 					   u32 index);
51 
52 /**
53  * gsi_channel_trans_complete() - Return a channel's next completed transaction
54  * @channel:	Channel whose next transaction is to be returned
55  *
56  * @Return:	The next completed transaction, or NULL if nothing new
57  */
58 struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel);
59 
60 /**
61  * gsi_channel_trans_cancel_pending() - Cancel pending transactions
62  * @channel:	Channel whose pending transactions should be cancelled
63  *
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.
68  *
69  * NOTE:  Transactions already complete at the time of this call are
70  *	  unaffected.
71  */
72 void gsi_channel_trans_cancel_pending(struct gsi_channel *channel);
73 
74 /**
75  * gsi_channel_trans_init() - Initialize a channel's GSI transaction info
76  * @gsi:	GSI pointer
77  * @channel_id:	Channel number
78  *
79  * @Return:	0 if successful, or -ENOMEM on allocation failure
80  *
81  * Creates and sets up information for managing transactions on a channel
82  */
83 int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id);
84 
85 /**
86  * gsi_channel_trans_exit() - Inverse of gsi_channel_trans_init()
87  * @channel:	Channel whose transaction information is to be cleaned up
88  */
89 void gsi_channel_trans_exit(struct gsi_channel *channel);
90 
91 /**
92  * gsi_channel_doorbell() - Ring a channel's doorbell
93  * @channel:	Channel whose doorbell should be rung
94  *
95  * Rings a channel's doorbell to inform the GSI hardware that new
96  * transactions (TREs, really) are available for it to process.
97  */
98 void gsi_channel_doorbell(struct gsi_channel *channel);
99 
100 /**
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
104  */
105 void *gsi_ring_virt(struct gsi_ring *ring, u32 index);
106 
107 /**
108  * gsi_channel_tx_queued() - Report the number of bytes queued to hardware
109  * @channel:	Channel whose bytes have been queued
110  *
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.
115  */
116 void gsi_channel_tx_queued(struct gsi_channel *channel);
117 
118 #endif /* _GSI_PRIVATE_H_ */
119