hcalls.h 6.8 KB

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