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