cvmx-pki-resources.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2020 Marvell International Ltd.
  4. *
  5. * Resource management for PKI resources.
  6. */
  7. #ifndef __CVMX_PKI_RESOURCES_H__
  8. #define __CVMX_PKI_RESOURCES_H__
  9. /**
  10. * This function allocates/reserves a style from pool of global styles per node.
  11. * @param node node to allocate style from.
  12. * @param style style to allocate, if -1 it will be allocated
  13. first available style from style resource. If index is positive
  14. number and in range, it will try to allocate specified style.
  15. * Return: style number on success, -1 on failure.
  16. */
  17. int cvmx_pki_style_alloc(int node, int style);
  18. /**
  19. * This function allocates/reserves a cluster group from per node
  20. cluster group resources.
  21. * @param node node to allocate cluster group from.
  22. @param cl_grp cluster group to allocate/reserve, if -1 ,
  23. allocate any available cluster group.
  24. * Return: cluster group number or -1 on failure
  25. */
  26. int cvmx_pki_cluster_grp_alloc(int node, int cl_grp);
  27. /**
  28. * This function allocates/reserves a cluster from per node
  29. cluster resources.
  30. * @param node node to allocate cluster group from.
  31. @param cluster_mask mask of clusters to allocate/reserve, if -1 ,
  32. allocate any available clusters.
  33. * @param num_clusters number of clusters that will be allocated
  34. */
  35. int cvmx_pki_cluster_alloc(int node, int num_clusters, u64 *cluster_mask);
  36. /**
  37. * This function allocates/reserves a pcam entry from node
  38. * @param node node to allocate pcam entry from.
  39. @param index index of pacm entry (0-191), if -1 ,
  40. allocate any available pcam entry.
  41. * @param bank pcam bank where to allocate/reserve pcan entry from
  42. * @param cluster_mask mask of clusters from which pcam entry is needed.
  43. * Return: pcam entry of -1 on failure
  44. */
  45. int cvmx_pki_pcam_entry_alloc(int node, int index, int bank, u64 cluster_mask);
  46. /**
  47. * This function allocates/reserves QPG table entries per node.
  48. * @param node node number.
  49. * @param base_offset base_offset in qpg table. If -1, first available
  50. qpg base_offset will be allocated. If base_offset is positive
  51. number and in range, it will try to allocate specified base_offset.
  52. @param count number of consecutive qpg entries to allocate. They will be consecutive
  53. from base offset.
  54. * Return: qpg table base offset number on success, -1 on failure.
  55. */
  56. int cvmx_pki_qpg_entry_alloc(int node, int base_offset, int count);
  57. /**
  58. * This function frees a style from pool of global styles per node.
  59. * @param node node to free style from.
  60. * @param style style to free
  61. * Return: 0 on success, -1 on failure.
  62. */
  63. int cvmx_pki_style_free(int node, int style);
  64. /**
  65. * This function frees a cluster group from per node
  66. cluster group resources.
  67. * @param node node to free cluster group from.
  68. @param cl_grp cluster group to free
  69. * Return: 0 on success or -1 on failure
  70. */
  71. int cvmx_pki_cluster_grp_free(int node, int cl_grp);
  72. /**
  73. * This function frees QPG table entries per node.
  74. * @param node node number.
  75. * @param base_offset base_offset in qpg table. If -1, first available
  76. * qpg base_offset will be allocated. If base_offset is positive
  77. * number and in range, it will try to allocate specified base_offset.
  78. * @param count number of consecutive qpg entries to allocate. They will be consecutive
  79. * from base offset.
  80. * Return: qpg table base offset number on success, -1 on failure.
  81. */
  82. int cvmx_pki_qpg_entry_free(int node, int base_offset, int count);
  83. /**
  84. * This function frees clusters from per node
  85. clusters resources.
  86. * @param node node to free clusters from.
  87. * @param cluster_mask mask of clusters need freeing
  88. * Return: 0 on success or -1 on failure
  89. */
  90. int cvmx_pki_cluster_free(int node, u64 cluster_mask);
  91. /**
  92. * This function frees a pcam entry from node
  93. * @param node node to allocate pcam entry from.
  94. @param index index of pacm entry (0-191) needs to be freed.
  95. * @param bank pcam bank where to free pcam entry from
  96. * @param cluster_mask mask of clusters from which pcam entry is freed.
  97. * Return: 0 on success OR -1 on failure
  98. */
  99. int cvmx_pki_pcam_entry_free(int node, int index, int bank, u64 cluster_mask);
  100. /**
  101. * This function allocates/reserves a bpid from pool of global bpid per node.
  102. * @param node node to allocate bpid from.
  103. * @param bpid bpid to allocate, if -1 it will be allocated
  104. * first available boid from bpid resource. If index is positive
  105. * number and in range, it will try to allocate specified bpid.
  106. * Return: bpid number on success,
  107. * -1 on alloc failure.
  108. * -2 on resource already reserved.
  109. */
  110. int cvmx_pki_bpid_alloc(int node, int bpid);
  111. /**
  112. * This function frees a bpid from pool of global bpid per node.
  113. * @param node node to free bpid from.
  114. * @param bpid bpid to free
  115. * Return: 0 on success, -1 on failure or
  116. */
  117. int cvmx_pki_bpid_free(int node, int bpid);
  118. /**
  119. * This function frees all the PKI software resources
  120. * (clusters, styles, qpg_entry, pcam_entry etc) for the specified node
  121. */
  122. /**
  123. * This function allocates/reserves an index from pool of global MTAG-IDX per node.
  124. * @param node node to allocate index from.
  125. * @param idx index to allocate, if -1 it will be allocated
  126. * Return: MTAG index number on success,
  127. * -1 on alloc failure.
  128. * -2 on resource already reserved.
  129. */
  130. int cvmx_pki_mtag_idx_alloc(int node, int idx);
  131. /**
  132. * This function frees an index from pool of global MTAG-IDX per node.
  133. * @param node node to free bpid from.
  134. * @param bpid bpid to free
  135. * Return: 0 on success, -1 on failure or
  136. */
  137. int cvmx_pki_mtag_idx_free(int node, int idx);
  138. void __cvmx_pki_global_rsrc_free(int node);
  139. #endif /* __CVM_PKI_RESOURCES_H__ */