Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. |
Alex Elder | a4388da | 2022-09-30 17:45:49 -0500 | [diff] [blame] | 4 | * Copyright (C) 2018-2022 Linaro Ltd. |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 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 | |
Alex Elder | 19aaf72 | 2021-03-28 12:31:10 -0500 | [diff] [blame] | 17 | #define GSI_RING_ELEMENT_SIZE 16 /* bytes; must be a power of 2 */ |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 18 | |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 19 | /** |
| 20 | * gsi_trans_move_complete() - Mark a GSI transaction completed |
Alex Elder | ace5dc6 | 2022-09-30 17:45:27 -0500 | [diff] [blame] | 21 | * @trans: Transaction whose state is to be updated |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 22 | */ |
| 23 | void gsi_trans_move_complete(struct gsi_trans *trans); |
| 24 | |
| 25 | /** |
| 26 | * gsi_trans_move_polled() - Mark a transaction polled |
Alex Elder | ace5dc6 | 2022-09-30 17:45:27 -0500 | [diff] [blame] | 27 | * @trans: Transaction whose state is to be updated |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 28 | */ |
| 29 | void gsi_trans_move_polled(struct gsi_trans *trans); |
| 30 | |
| 31 | /** |
| 32 | * gsi_trans_complete() - Complete a GSI transaction |
| 33 | * @trans: Transaction to complete |
| 34 | * |
| 35 | * Marks a transaction complete (including freeing it). |
| 36 | */ |
| 37 | void gsi_trans_complete(struct gsi_trans *trans); |
| 38 | |
| 39 | /** |
| 40 | * gsi_channel_trans_mapped() - Return a transaction mapped to a TRE index |
| 41 | * @channel: Channel associated with the transaction |
| 42 | * @index: Index of the TRE having a transaction |
| 43 | * |
Alex Elder | e3eea08 | 2020-07-13 07:24:18 -0500 | [diff] [blame] | 44 | * Return: The GSI transaction pointer associated with the TRE index |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 45 | */ |
| 46 | struct gsi_trans *gsi_channel_trans_mapped(struct gsi_channel *channel, |
| 47 | u32 index); |
| 48 | |
| 49 | /** |
| 50 | * gsi_channel_trans_complete() - Return a channel's next completed transaction |
| 51 | * @channel: Channel whose next transaction is to be returned |
| 52 | * |
Alex Elder | e3eea08 | 2020-07-13 07:24:18 -0500 | [diff] [blame] | 53 | * Return: The next completed transaction, or NULL if nothing new |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 54 | */ |
| 55 | struct gsi_trans *gsi_channel_trans_complete(struct gsi_channel *channel); |
| 56 | |
| 57 | /** |
| 58 | * gsi_channel_trans_cancel_pending() - Cancel pending transactions |
| 59 | * @channel: Channel whose pending transactions should be cancelled |
| 60 | * |
| 61 | * Cancel all pending transactions on a channel. These are transactions |
| 62 | * that have been committed but not yet completed. This is required when |
| 63 | * the channel gets reset. At that time all pending transactions will be |
| 64 | * marked as cancelled. |
| 65 | * |
| 66 | * NOTE: Transactions already complete at the time of this call are |
| 67 | * unaffected. |
| 68 | */ |
| 69 | void gsi_channel_trans_cancel_pending(struct gsi_channel *channel); |
| 70 | |
| 71 | /** |
| 72 | * gsi_channel_trans_init() - Initialize a channel's GSI transaction info |
| 73 | * @gsi: GSI pointer |
| 74 | * @channel_id: Channel number |
| 75 | * |
Alex Elder | e3eea08 | 2020-07-13 07:24:18 -0500 | [diff] [blame] | 76 | * Return: 0 if successful, or -ENOMEM on allocation failure |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 77 | * |
| 78 | * Creates and sets up information for managing transactions on a channel |
| 79 | */ |
| 80 | int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id); |
| 81 | |
| 82 | /** |
| 83 | * gsi_channel_trans_exit() - Inverse of gsi_channel_trans_init() |
| 84 | * @channel: Channel whose transaction information is to be cleaned up |
| 85 | */ |
| 86 | void gsi_channel_trans_exit(struct gsi_channel *channel); |
| 87 | |
| 88 | /** |
| 89 | * gsi_channel_doorbell() - Ring a channel's doorbell |
| 90 | * @channel: Channel whose doorbell should be rung |
| 91 | * |
| 92 | * Rings a channel's doorbell to inform the GSI hardware that new |
| 93 | * transactions (TREs, really) are available for it to process. |
| 94 | */ |
| 95 | void gsi_channel_doorbell(struct gsi_channel *channel); |
| 96 | |
Alex Elder | e0e3406 | 2022-09-06 12:19:41 -0500 | [diff] [blame] | 97 | /* gsi_channel_update() - Update knowledge of channel hardware state |
Alex Elder | 019e37e | 2022-09-06 12:19:42 -0500 | [diff] [blame] | 98 | * @channel: Channel to be updated |
Alex Elder | e0e3406 | 2022-09-06 12:19:41 -0500 | [diff] [blame] | 99 | * |
Alex Elder | ace5dc6 | 2022-09-30 17:45:27 -0500 | [diff] [blame] | 100 | * Consult hardware, change the state of any newly-completed transactions |
| 101 | * on a channel. |
Alex Elder | e0e3406 | 2022-09-06 12:19:41 -0500 | [diff] [blame] | 102 | */ |
Alex Elder | 019e37e | 2022-09-06 12:19:42 -0500 | [diff] [blame] | 103 | void gsi_channel_update(struct gsi_channel *channel); |
Alex Elder | e0e3406 | 2022-09-06 12:19:41 -0500 | [diff] [blame] | 104 | |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 105 | /** |
| 106 | * gsi_ring_virt() - Return virtual address for a ring entry |
| 107 | * @ring: Ring whose address is to be translated |
Alex Elder | 862d3f2 | 2021-03-28 12:31:05 -0500 | [diff] [blame] | 108 | * @index: Index (slot number) of entry |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 109 | */ |
| 110 | void *gsi_ring_virt(struct gsi_ring *ring, u32 index); |
| 111 | |
| 112 | /** |
Alex Elder | 4e0f28e | 2022-06-13 12:17:56 -0500 | [diff] [blame] | 113 | * gsi_trans_tx_committed() - Record bytes committed for transmit |
| 114 | * @trans: TX endpoint transaction being committed |
| 115 | * |
| 116 | * Report that a TX transaction has been committed. It updates some |
| 117 | * statistics used to manage transmit rates. |
| 118 | */ |
| 119 | void gsi_trans_tx_committed(struct gsi_trans *trans); |
| 120 | |
| 121 | /** |
Alex Elder | bcec9ec | 2022-06-10 10:46:15 -0500 | [diff] [blame] | 122 | * gsi_trans_tx_queued() - Report a queued TX channel transaction |
| 123 | * @trans: Transaction being passed to hardware |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 124 | * |
Alex Elder | bcec9ec | 2022-06-10 10:46:15 -0500 | [diff] [blame] | 125 | * Report to the network stack that a TX transaction is being supplied |
| 126 | * to the hardware. |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 127 | */ |
Alex Elder | bcec9ec | 2022-06-10 10:46:15 -0500 | [diff] [blame] | 128 | void gsi_trans_tx_queued(struct gsi_trans *trans); |
Alex Elder | ca48b27 | 2020-03-05 22:28:20 -0600 | [diff] [blame] | 129 | |
| 130 | #endif /* _GSI_PRIVATE_H_ */ |