cxl.h 3.8 KB

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