hcalls.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright 2015 IBM Corp.
  4. */
  5. #ifndef _HCALLS_H
  6. #define _HCALLS_H
  7. #include <linux/types.h>
  8. #include <asm/byteorder.h>
  9. #include <asm/hvcall.h>
  10. #include "cxl.h"
  11. #define SG_BUFFER_SIZE 4096
  12. #define SG_MAX_ENTRIES 256
  13. struct sg_list {
  14. u64 phys_addr;
  15. u64 len;
  16. };
  17. /*
  18. * This is straight out of PAPR, but replacing some of the compound fields with
  19. * a single field, where they were identical to the register layout.
  20. *
  21. * The 'flags' parameter regroups the various bit-fields
  22. */
  23. #define CXL_PE_CSRP_VALID (1ULL << 63)
  24. #define CXL_PE_PROBLEM_STATE (1ULL << 62)
  25. #define CXL_PE_SECONDARY_SEGMENT_TBL_SRCH (1ULL << 61)
  26. #define CXL_PE_TAGS_ACTIVE (1ULL << 60)
  27. #define CXL_PE_USER_STATE (1ULL << 59)
  28. #define CXL_PE_TRANSLATION_ENABLED (1ULL << 58)
  29. #define CXL_PE_64_BIT (1ULL << 57)
  30. #define CXL_PE_PRIVILEGED_PROCESS (1ULL << 56)
  31. #define CXL_PROCESS_ELEMENT_VERSION 1
  32. struct cxl_process_element_hcall {
  33. __be64 version;
  34. __be64 flags;
  35. u8 reserved0[12];
  36. __be32 pslVirtualIsn;
  37. u8 applicationVirtualIsnBitmap[256];
  38. u8 reserved1[144];
  39. struct cxl_process_element_common common;
  40. u8 reserved4[12];
  41. } __packed;
  42. #define H_STATE_NORMAL 1
  43. #define H_STATE_DISABLE 2
  44. #define H_STATE_TEMP_UNAVAILABLE 3
  45. #define H_STATE_PERM_UNAVAILABLE 4
  46. /* NOTE: element must be a logical real address, and must be pinned */
  47. long cxl_h_attach_process(u64 unit_address, struct cxl_process_element_hcall *element,
  48. u64 *process_token, u64 *mmio_addr, u64 *mmio_size);
  49. /**
  50. * cxl_h_detach_process - Detach a process element from a coherent
  51. * platform function.
  52. */
  53. long cxl_h_detach_process(u64 unit_address, u64 process_token);
  54. /**
  55. * cxl_h_reset_afu - Perform a reset to the coherent platform function.
  56. */
  57. long cxl_h_reset_afu(u64 unit_address);
  58. /**
  59. * cxl_h_suspend_process - Suspend a process from being executed
  60. * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
  61. * process was attached.
  62. */
  63. long cxl_h_suspend_process(u64 unit_address, u64 process_token);
  64. /**
  65. * cxl_h_resume_process - Resume a process to be executed
  66. * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
  67. * process was attached.
  68. */
  69. long cxl_h_resume_process(u64 unit_address, u64 process_token);
  70. /**
  71. * cxl_h_read_error_state - Reads the error state of the coherent
  72. * platform function.
  73. * R4 contains the error state
  74. */
  75. long cxl_h_read_error_state(u64 unit_address, u64 *state);
  76. /**
  77. * cxl_h_get_afu_err - collect the AFU error buffer
  78. * Parameter1 = byte offset into error buffer to retrieve, valid values
  79. * are between 0 and (ibm,error-buffer-size - 1)
  80. * Parameter2 = 4K aligned real address of error buffer, to be filled in
  81. * Parameter3 = length of error buffer, valid values are 4K or less
  82. */
  83. long cxl_h_get_afu_err(u64 unit_address, u64 offset, u64 buf_address, u64 len);
  84. /**
  85. * cxl_h_get_config - collect configuration record for the
  86. * coherent platform function
  87. * Parameter1 = # of configuration record to retrieve, valid values are
  88. * between 0 and (ibm,#config-records - 1)
  89. * Parameter2 = byte offset into configuration record to retrieve,
  90. * valid values are between 0 and (ibm,config-record-size - 1)
  91. * Parameter3 = 4K aligned real address of configuration record buffer,
  92. * to be filled in
  93. * Parameter4 = length of configuration buffer, valid values are 4K or less
  94. */
  95. long cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset,
  96. u64 buf_address, u64 len);
  97. /**
  98. * cxl_h_terminate_process - Terminate the process before completion
  99. * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
  100. * process was attached.
  101. */
  102. long cxl_h_terminate_process(u64 unit_address, u64 process_token);
  103. /**
  104. * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
  105. * Parameter1 = # of VPD record to retrieve, valid values are between 0
  106. * and (ibm,#config-records - 1).
  107. * Parameter2 = 4K naturally aligned real buffer containing block
  108. * list entries
  109. * Parameter3 = number of block list entries in the block list, valid
  110. * values are between 0 and 256
  111. */
  112. long cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address,
  113. u64 num, u64 *out);
  114. /**
  115. * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt
  116. */
  117. long cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg);
  118. /**
  119. * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data
  120. * based on an interrupt
  121. * Parameter1 = value to write to the function-wide error interrupt register
  122. */
  123. long cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value);
  124. /**
  125. * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of
  126. * an error log
  127. */
  128. long cxl_h_get_error_log(u64 unit_address, u64 value);
  129. /**
  130. * cxl_h_collect_int_info - Collect interrupt info about a coherent
  131. * platform function after an interrupt occurred.
  132. */
  133. long cxl_h_collect_int_info(u64 unit_address, u64 process_token,
  134. struct cxl_irq_info *info);
  135. /**
  136. * cxl_h_control_faults - Control the operation of a coherent platform
  137. * function after a fault occurs.
  138. *
  139. * Parameters
  140. * control-mask: value to control the faults
  141. * looks like PSL_TFC_An shifted >> 32
  142. * reset-mask: mask to control reset of function faults
  143. * Set reset_mask = 1 to reset PSL errors
  144. */
  145. long cxl_h_control_faults(u64 unit_address, u64 process_token,
  146. u64 control_mask, u64 reset_mask);
  147. /**
  148. * cxl_h_reset_adapter - Perform a reset to the coherent platform facility.
  149. */
  150. long cxl_h_reset_adapter(u64 unit_address);
  151. /**
  152. * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
  153. * Parameter1 = 4K naturally aligned real buffer containing block
  154. * list entries
  155. * Parameter2 = number of block list entries in the block list, valid
  156. * values are between 0 and 256
  157. */
  158. long cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address,
  159. u64 num, u64 *out);
  160. /**
  161. * cxl_h_download_adapter_image - Download the base image to the coherent
  162. * platform facility.
  163. */
  164. long cxl_h_download_adapter_image(u64 unit_address,
  165. u64 list_address, u64 num,
  166. u64 *out);
  167. /**
  168. * cxl_h_validate_adapter_image - Validate the base image in the coherent
  169. * platform facility.
  170. */
  171. long cxl_h_validate_adapter_image(u64 unit_address,
  172. u64 list_address, u64 num,
  173. u64 *out);
  174. #endif /* _HCALLS_H */