gsi_private.h 4.0 KB

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