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