gsi_private.h 4.0 KB

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