adf_transport_access_macros.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. This file is provided under a dual BSD/GPLv2 license. When using or
  3. redistributing this file, you may do so under either license.
  4. GPL LICENSE SUMMARY
  5. Copyright(c) 2014 Intel Corporation.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of version 2 of the GNU General Public License as
  8. published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful, but
  10. WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. General Public License for more details.
  13. Contact Information:
  14. qat-linux@intel.com
  15. BSD LICENSE
  16. Copyright(c) 2014 Intel Corporation.
  17. Redistribution and use in source and binary forms, with or without
  18. modification, are permitted provided that the following conditions
  19. are met:
  20. * Redistributions of source code must retain the above copyright
  21. notice, this list of conditions and the following disclaimer.
  22. * Redistributions in binary form must reproduce the above copyright
  23. notice, this list of conditions and the following disclaimer in
  24. the documentation and/or other materials provided with the
  25. distribution.
  26. * Neither the name of Intel Corporation nor the names of its
  27. contributors may be used to endorse or promote products derived
  28. from this software without specific prior written permission.
  29. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. */
  41. #ifndef ADF_TRANSPORT_ACCESS_MACROS_H
  42. #define ADF_TRANSPORT_ACCESS_MACROS_H
  43. #include "adf_accel_devices.h"
  44. #define ADF_BANK_INT_SRC_SEL_MASK_0 0x4444444CUL
  45. #define ADF_BANK_INT_SRC_SEL_MASK_X 0x44444444UL
  46. #define ADF_BANK_INT_FLAG_CLEAR_MASK 0xFFFF
  47. #define ADF_RING_CSR_RING_CONFIG 0x000
  48. #define ADF_RING_CSR_RING_LBASE 0x040
  49. #define ADF_RING_CSR_RING_UBASE 0x080
  50. #define ADF_RING_CSR_RING_HEAD 0x0C0
  51. #define ADF_RING_CSR_RING_TAIL 0x100
  52. #define ADF_RING_CSR_E_STAT 0x14C
  53. #define ADF_RING_CSR_INT_FLAG 0x170
  54. #define ADF_RING_CSR_INT_SRCSEL 0x174
  55. #define ADF_RING_CSR_INT_SRCSEL_2 0x178
  56. #define ADF_RING_CSR_INT_COL_EN 0x17C
  57. #define ADF_RING_CSR_INT_COL_CTL 0x180
  58. #define ADF_RING_CSR_INT_FLAG_AND_COL 0x184
  59. #define ADF_RING_CSR_INT_COL_CTL_ENABLE 0x80000000
  60. #define ADF_RING_BUNDLE_SIZE 0x1000
  61. #define ADF_RING_CONFIG_NEAR_FULL_WM 0x0A
  62. #define ADF_RING_CONFIG_NEAR_EMPTY_WM 0x05
  63. #define ADF_COALESCING_MIN_TIME 0x1FF
  64. #define ADF_COALESCING_MAX_TIME 0xFFFFF
  65. #define ADF_COALESCING_DEF_TIME 0x27FF
  66. #define ADF_RING_NEAR_WATERMARK_512 0x08
  67. #define ADF_RING_NEAR_WATERMARK_0 0x00
  68. #define ADF_RING_EMPTY_SIG 0x7F7F7F7F
  69. /* Valid internal ring size values */
  70. #define ADF_RING_SIZE_128 0x01
  71. #define ADF_RING_SIZE_256 0x02
  72. #define ADF_RING_SIZE_512 0x03
  73. #define ADF_RING_SIZE_4K 0x06
  74. #define ADF_RING_SIZE_16K 0x08
  75. #define ADF_RING_SIZE_4M 0x10
  76. #define ADF_MIN_RING_SIZE ADF_RING_SIZE_128
  77. #define ADF_MAX_RING_SIZE ADF_RING_SIZE_4M
  78. #define ADF_DEFAULT_RING_SIZE ADF_RING_SIZE_16K
  79. /* Valid internal msg size values */
  80. #define ADF_MSG_SIZE_32 0x01
  81. #define ADF_MSG_SIZE_64 0x02
  82. #define ADF_MSG_SIZE_128 0x04
  83. #define ADF_MIN_MSG_SIZE ADF_MSG_SIZE_32
  84. #define ADF_MAX_MSG_SIZE ADF_MSG_SIZE_128
  85. /* Size to bytes conversion macros for ring and msg size values */
  86. #define ADF_MSG_SIZE_TO_BYTES(SIZE) (SIZE << 5)
  87. #define ADF_BYTES_TO_MSG_SIZE(SIZE) (SIZE >> 5)
  88. #define ADF_SIZE_TO_RING_SIZE_IN_BYTES(SIZE) ((1 << (SIZE - 1)) << 7)
  89. #define ADF_RING_SIZE_IN_BYTES_TO_SIZE(SIZE) ((1 << (SIZE - 1)) >> 7)
  90. /* Minimum ring bufer size for memory allocation */
  91. #define ADF_RING_SIZE_BYTES_MIN(SIZE) \
  92. ((SIZE < ADF_SIZE_TO_RING_SIZE_IN_BYTES(ADF_RING_SIZE_4K)) ? \
  93. ADF_SIZE_TO_RING_SIZE_IN_BYTES(ADF_RING_SIZE_4K) : SIZE)
  94. #define ADF_RING_SIZE_MODULO(SIZE) (SIZE + 0x6)
  95. #define ADF_SIZE_TO_POW(SIZE) ((((SIZE & 0x4) >> 1) | ((SIZE & 0x4) >> 2) | \
  96. SIZE) & ~0x4)
  97. /* Max outstanding requests */
  98. #define ADF_MAX_INFLIGHTS(RING_SIZE, MSG_SIZE) \
  99. ((((1 << (RING_SIZE - 1)) << 3) >> ADF_SIZE_TO_POW(MSG_SIZE)) - 1)
  100. #define BUILD_RING_CONFIG(size) \
  101. ((ADF_RING_NEAR_WATERMARK_0 << ADF_RING_CONFIG_NEAR_FULL_WM) \
  102. | (ADF_RING_NEAR_WATERMARK_0 << ADF_RING_CONFIG_NEAR_EMPTY_WM) \
  103. | size)
  104. #define BUILD_RESP_RING_CONFIG(size, watermark_nf, watermark_ne) \
  105. ((watermark_nf << ADF_RING_CONFIG_NEAR_FULL_WM) \
  106. | (watermark_ne << ADF_RING_CONFIG_NEAR_EMPTY_WM) \
  107. | size)
  108. #define BUILD_RING_BASE_ADDR(addr, size) \
  109. ((addr >> 6) & (0xFFFFFFFFFFFFFFFFULL << size))
  110. #define READ_CSR_RING_HEAD(csr_base_addr, bank, ring) \
  111. ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  112. ADF_RING_CSR_RING_HEAD + (ring << 2))
  113. #define READ_CSR_RING_TAIL(csr_base_addr, bank, ring) \
  114. ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  115. ADF_RING_CSR_RING_TAIL + (ring << 2))
  116. #define READ_CSR_E_STAT(csr_base_addr, bank) \
  117. ADF_CSR_RD(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  118. ADF_RING_CSR_E_STAT)
  119. #define WRITE_CSR_RING_CONFIG(csr_base_addr, bank, ring, value) \
  120. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  121. ADF_RING_CSR_RING_CONFIG + (ring << 2), value)
  122. #define WRITE_CSR_RING_BASE(csr_base_addr, bank, ring, value) \
  123. do { \
  124. uint32_t l_base = 0, u_base = 0; \
  125. l_base = (uint32_t)(value & 0xFFFFFFFF); \
  126. u_base = (uint32_t)((value & 0xFFFFFFFF00000000ULL) >> 32); \
  127. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  128. ADF_RING_CSR_RING_LBASE + (ring << 2), l_base); \
  129. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  130. ADF_RING_CSR_RING_UBASE + (ring << 2), u_base); \
  131. } while (0)
  132. #define WRITE_CSR_RING_HEAD(csr_base_addr, bank, ring, value) \
  133. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  134. ADF_RING_CSR_RING_HEAD + (ring << 2), value)
  135. #define WRITE_CSR_RING_TAIL(csr_base_addr, bank, ring, value) \
  136. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  137. ADF_RING_CSR_RING_TAIL + (ring << 2), value)
  138. #define WRITE_CSR_INT_FLAG(csr_base_addr, bank, value) \
  139. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * (bank)) + \
  140. ADF_RING_CSR_INT_FLAG, value)
  141. #define WRITE_CSR_INT_SRCSEL(csr_base_addr, bank) \
  142. do { \
  143. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  144. ADF_RING_CSR_INT_SRCSEL, ADF_BANK_INT_SRC_SEL_MASK_0); \
  145. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  146. ADF_RING_CSR_INT_SRCSEL_2, ADF_BANK_INT_SRC_SEL_MASK_X); \
  147. } while (0)
  148. #define WRITE_CSR_INT_COL_EN(csr_base_addr, bank, value) \
  149. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  150. ADF_RING_CSR_INT_COL_EN, value)
  151. #define WRITE_CSR_INT_COL_CTL(csr_base_addr, bank, value) \
  152. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  153. ADF_RING_CSR_INT_COL_CTL, \
  154. ADF_RING_CSR_INT_COL_CTL_ENABLE | value)
  155. #define WRITE_CSR_INT_FLAG_AND_COL(csr_base_addr, bank, value) \
  156. ADF_CSR_WR(csr_base_addr, (ADF_RING_BUNDLE_SIZE * bank) + \
  157. ADF_RING_CSR_INT_FLAG_AND_COL, value)
  158. #endif