cxl.h 3.9 KB

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