xref: /OK3568_Linux_fs/kernel/drivers/net/ipa/gsi_private.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun 
3*4882a593Smuzhiyun /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4*4882a593Smuzhiyun  * Copyright (C) 2018-2020 Linaro Ltd.
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef _GSI_PRIVATE_H_
7*4882a593Smuzhiyun #define _GSI_PRIVATE_H_
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /* === Only "gsi.c" and "gsi_trans.c" should include this file === */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <linux/types.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun struct gsi_trans;
14*4882a593Smuzhiyun struct gsi_ring;
15*4882a593Smuzhiyun struct gsi_channel;
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #define GSI_RING_ELEMENT_SIZE	16	/* bytes; must be a power of 2 */
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun /* Return the entry that follows one provided in a transaction pool */
20*4882a593Smuzhiyun void *gsi_trans_pool_next(struct gsi_trans_pool *pool, void *element);
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /**
23*4882a593Smuzhiyun  * gsi_trans_move_complete() - Mark a GSI transaction completed
24*4882a593Smuzhiyun  * @trans:	Transaction to commit
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun void gsi_trans_move_complete(struct gsi_trans *trans);
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun /**
29*4882a593Smuzhiyun  * gsi_trans_move_polled() - Mark a transaction polled
30*4882a593Smuzhiyun  * @trans:	Transaction to update
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun void gsi_trans_move_polled(struct gsi_trans *trans);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun /**
35*4882a593Smuzhiyun  * gsi_trans_complete() - Complete a GSI transaction
36*4882a593Smuzhiyun  * @trans:	Transaction to complete
37*4882a593Smuzhiyun  *
38*4882a593Smuzhiyun  * Marks a transaction complete (including freeing it).
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun void gsi_trans_complete(struct gsi_trans *trans);
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /**
43*4882a593Smuzhiyun  * gsi_channel_trans_mapped() - Return a transaction mapped to a TRE index
44*4882a593Smuzhiyun  * @channel:	Channel associated with the transaction
45*4882a593Smuzhiyun  * @index:	Index of the TRE having a transaction
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * Return:	The GSI transaction pointer associated with the TRE index
48*4882a593Smuzhiyun  */
49*4882a593Smuzhiyun struct gsi_trans *gsi_channel_trans_mapped(struct gsi_channel *channel,
50*4882a593Smuzhiyun 					   u32 index);
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /**
53*4882a593Smuzhiyun  * gsi_channel_trans_complete() - Return a channel's next completed transaction
54*4882a593Smuzhiyun  * @channel:	Channel whose next transaction is to be returned
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * Return:	The next completed transaction, or NULL if nothing new
57*4882a593Smuzhiyun  */
58*4882a593Smuzhiyun struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel);
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun /**
61*4882a593Smuzhiyun  * gsi_channel_trans_cancel_pending() - Cancel pending transactions
62*4882a593Smuzhiyun  * @channel:	Channel whose pending transactions should be cancelled
63*4882a593Smuzhiyun  *
64*4882a593Smuzhiyun  * Cancel all pending transactions on a channel.  These are transactions
65*4882a593Smuzhiyun  * that have been committed but not yet completed.  This is required when
66*4882a593Smuzhiyun  * the channel gets reset.  At that time all pending transactions will be
67*4882a593Smuzhiyun  * marked as cancelled.
68*4882a593Smuzhiyun  *
69*4882a593Smuzhiyun  * NOTE:  Transactions already complete at the time of this call are
70*4882a593Smuzhiyun  *	  unaffected.
71*4882a593Smuzhiyun  */
72*4882a593Smuzhiyun void gsi_channel_trans_cancel_pending(struct gsi_channel *channel);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * gsi_channel_trans_init() - Initialize a channel's GSI transaction info
76*4882a593Smuzhiyun  * @gsi:	GSI pointer
77*4882a593Smuzhiyun  * @channel_id:	Channel number
78*4882a593Smuzhiyun  *
79*4882a593Smuzhiyun  * Return:	0 if successful, or -ENOMEM on allocation failure
80*4882a593Smuzhiyun  *
81*4882a593Smuzhiyun  * Creates and sets up information for managing transactions on a channel
82*4882a593Smuzhiyun  */
83*4882a593Smuzhiyun int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id);
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /**
86*4882a593Smuzhiyun  * gsi_channel_trans_exit() - Inverse of gsi_channel_trans_init()
87*4882a593Smuzhiyun  * @channel:	Channel whose transaction information is to be cleaned up
88*4882a593Smuzhiyun  */
89*4882a593Smuzhiyun void gsi_channel_trans_exit(struct gsi_channel *channel);
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun /**
92*4882a593Smuzhiyun  * gsi_channel_doorbell() - Ring a channel's doorbell
93*4882a593Smuzhiyun  * @channel:	Channel whose doorbell should be rung
94*4882a593Smuzhiyun  *
95*4882a593Smuzhiyun  * Rings a channel's doorbell to inform the GSI hardware that new
96*4882a593Smuzhiyun  * transactions (TREs, really) are available for it to process.
97*4882a593Smuzhiyun  */
98*4882a593Smuzhiyun void gsi_channel_doorbell(struct gsi_channel *channel);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun /**
101*4882a593Smuzhiyun  * gsi_ring_virt() - Return virtual address for a ring entry
102*4882a593Smuzhiyun  * @ring:	Ring whose address is to be translated
103*4882a593Smuzhiyun  * @addr:	Index (slot number) of entry
104*4882a593Smuzhiyun  */
105*4882a593Smuzhiyun void *gsi_ring_virt(struct gsi_ring *ring, u32 index);
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun /**
108*4882a593Smuzhiyun  * gsi_channel_tx_queued() - Report the number of bytes queued to hardware
109*4882a593Smuzhiyun  * @channel:	Channel whose bytes have been queued
110*4882a593Smuzhiyun  *
111*4882a593Smuzhiyun  * This arranges for the the number of transactions and bytes for
112*4882a593Smuzhiyun  * transfer that have been queued to hardware to be reported.  It
113*4882a593Smuzhiyun  * passes this information up the network stack so it can be used to
114*4882a593Smuzhiyun  * throttle transmissions.
115*4882a593Smuzhiyun  */
116*4882a593Smuzhiyun void gsi_channel_tx_queued(struct gsi_channel *channel);
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun #endif /* _GSI_PRIVATE_H_ */
119