cxl.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright 2014 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 _UAPI_MISC_CXL_H
  10. #define _UAPI_MISC_CXL_H
  11. #include <linux/types.h>
  12. #include <linux/ioctl.h>
  13. struct cxl_ioctl_start_work {
  14. __u64 flags;
  15. __u64 work_element_descriptor;
  16. __u64 amr;
  17. __s16 num_interrupts;
  18. __s16 reserved1;
  19. __s32 reserved2;
  20. __u64 reserved3;
  21. __u64 reserved4;
  22. __u64 reserved5;
  23. __u64 reserved6;
  24. };
  25. #define CXL_START_WORK_AMR 0x0000000000000001ULL
  26. #define CXL_START_WORK_NUM_IRQS 0x0000000000000002ULL
  27. #define CXL_START_WORK_ERR_FF 0x0000000000000004ULL
  28. #define CXL_START_WORK_ALL (CXL_START_WORK_AMR |\
  29. CXL_START_WORK_NUM_IRQS |\
  30. CXL_START_WORK_ERR_FF)
  31. /* Possible modes that an afu can be in */
  32. #define CXL_MODE_DEDICATED 0x1
  33. #define CXL_MODE_DIRECTED 0x2
  34. /* possible flags for the cxl_afu_id flags field */
  35. #define CXL_AFUID_FLAG_SLAVE 0x1 /* In directed-mode afu is in slave mode */
  36. struct cxl_afu_id {
  37. __u64 flags; /* One of CXL_AFUID_FLAG_X */
  38. __u32 card_id;
  39. __u32 afu_offset;
  40. __u32 afu_mode; /* one of the CXL_MODE_X */
  41. __u32 reserved1;
  42. __u64 reserved2;
  43. __u64 reserved3;
  44. __u64 reserved4;
  45. __u64 reserved5;
  46. __u64 reserved6;
  47. };
  48. /* base adapter image header is included in the image */
  49. #define CXL_AI_NEED_HEADER 0x0000000000000001ULL
  50. #define CXL_AI_ALL CXL_AI_NEED_HEADER
  51. #define CXL_AI_HEADER_SIZE 128
  52. #define CXL_AI_BUFFER_SIZE 4096
  53. #define CXL_AI_MAX_ENTRIES 256
  54. #define CXL_AI_MAX_CHUNK_SIZE (CXL_AI_BUFFER_SIZE * CXL_AI_MAX_ENTRIES)
  55. struct cxl_adapter_image {
  56. __u64 flags;
  57. __u64 data;
  58. __u64 len_data;
  59. __u64 len_image;
  60. __u64 reserved1;
  61. __u64 reserved2;
  62. __u64 reserved3;
  63. __u64 reserved4;
  64. };
  65. /* ioctl numbers */
  66. #define CXL_MAGIC 0xCA
  67. /* AFU devices */
  68. #define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
  69. #define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
  70. #define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
  71. /* adapter devices */
  72. #define CXL_IOCTL_DOWNLOAD_IMAGE _IOW(CXL_MAGIC, 0x0A, struct cxl_adapter_image)
  73. #define CXL_IOCTL_VALIDATE_IMAGE _IOW(CXL_MAGIC, 0x0B, struct cxl_adapter_image)
  74. #define CXL_READ_MIN_SIZE 0x1000 /* 4K */
  75. /* Events from read() */
  76. enum cxl_event_type {
  77. CXL_EVENT_RESERVED = 0,
  78. CXL_EVENT_AFU_INTERRUPT = 1,
  79. CXL_EVENT_DATA_STORAGE = 2,
  80. CXL_EVENT_AFU_ERROR = 3,
  81. CXL_EVENT_AFU_DRIVER = 4,
  82. };
  83. struct cxl_event_header {
  84. __u16 type;
  85. __u16 size;
  86. __u16 process_element;
  87. __u16 reserved1;
  88. };
  89. struct cxl_event_afu_interrupt {
  90. __u16 flags;
  91. __u16 irq; /* Raised AFU interrupt number */
  92. __u32 reserved1;
  93. };
  94. struct cxl_event_data_storage {
  95. __u16 flags;
  96. __u16 reserved1;
  97. __u32 reserved2;
  98. __u64 addr;
  99. __u64 dsisr;
  100. __u64 reserved3;
  101. };
  102. struct cxl_event_afu_error {
  103. __u16 flags;
  104. __u16 reserved1;
  105. __u32 reserved2;
  106. __u64 error;
  107. };
  108. struct cxl_event_afu_driver_reserved {
  109. /*
  110. * Defines the buffer passed to the cxl driver by the AFU driver.
  111. *
  112. * This is not ABI since the event header.size passed to the user for
  113. * existing events is set in the read call to sizeof(cxl_event_header)
  114. * + sizeof(whatever event is being dispatched) and the user is already
  115. * required to use a 4K buffer on the read call.
  116. *
  117. * Of course the contents will be ABI, but that's up the AFU driver.
  118. */
  119. __u32 data_size;
  120. __u8 data[];
  121. };
  122. struct cxl_event {
  123. struct cxl_event_header header;
  124. union {
  125. struct cxl_event_afu_interrupt irq;
  126. struct cxl_event_data_storage fault;
  127. struct cxl_event_afu_error afu_error;
  128. struct cxl_event_afu_driver_reserved afu_driver_event;
  129. };
  130. };
  131. #endif /* _UAPI_MISC_CXL_H */