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