cxlflash_ioctl.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * CXL Flash Device Driver
  3. *
  4. * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
  5. * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
  6. *
  7. * Copyright (C) 2015 IBM Corporation
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #ifndef _CXLFLASH_IOCTL_H
  15. #define _CXLFLASH_IOCTL_H
  16. #include <linux/types.h>
  17. /*
  18. * Structure and flag definitions CXL Flash superpipe ioctls
  19. */
  20. #define DK_CXLFLASH_VERSION_0 0
  21. struct dk_cxlflash_hdr {
  22. __u16 version; /* Version data */
  23. __u16 rsvd[3]; /* Reserved for future use */
  24. __u64 flags; /* Input flags */
  25. __u64 return_flags; /* Returned flags */
  26. };
  27. /*
  28. * Notes:
  29. * -----
  30. * The 'context_id' field of all ioctl structures contains the context
  31. * identifier for a context in the lower 32-bits (upper 32-bits are not
  32. * to be used when identifying a context to the AFU). That said, the value
  33. * in its entirety (all 64-bits) is to be treated as an opaque cookie and
  34. * should be presented as such when issuing ioctls.
  35. *
  36. * For DK_CXLFLASH_ATTACH ioctl, user specifies read/write access
  37. * permissions via the O_RDONLY, O_WRONLY, and O_RDWR flags defined in
  38. * the fcntl.h header file.
  39. */
  40. #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
  41. struct dk_cxlflash_attach {
  42. struct dk_cxlflash_hdr hdr; /* Common fields */
  43. __u64 num_interrupts; /* Requested number of interrupts */
  44. __u64 context_id; /* Returned context */
  45. __u64 mmio_size; /* Returned size of MMIO area */
  46. __u64 block_size; /* Returned block size, in bytes */
  47. __u64 adap_fd; /* Returned adapter file descriptor */
  48. __u64 last_lba; /* Returned last LBA on the device */
  49. __u64 max_xfer; /* Returned max transfer size, blocks */
  50. __u64 reserved[8]; /* Reserved for future use */
  51. };
  52. struct dk_cxlflash_detach {
  53. struct dk_cxlflash_hdr hdr; /* Common fields */
  54. __u64 context_id; /* Context to detach */
  55. __u64 reserved[8]; /* Reserved for future use */
  56. };
  57. struct dk_cxlflash_udirect {
  58. struct dk_cxlflash_hdr hdr; /* Common fields */
  59. __u64 context_id; /* Context to own physical resources */
  60. __u64 rsrc_handle; /* Returned resource handle */
  61. __u64 last_lba; /* Returned last LBA on the device */
  62. __u64 reserved[8]; /* Reserved for future use */
  63. };
  64. #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
  65. struct dk_cxlflash_uvirtual {
  66. struct dk_cxlflash_hdr hdr; /* Common fields */
  67. __u64 context_id; /* Context to own virtual resources */
  68. __u64 lun_size; /* Requested size, in 4K blocks */
  69. __u64 rsrc_handle; /* Returned resource handle */
  70. __u64 last_lba; /* Returned last LBA of LUN */
  71. __u64 reserved[8]; /* Reserved for future use */
  72. };
  73. struct dk_cxlflash_release {
  74. struct dk_cxlflash_hdr hdr; /* Common fields */
  75. __u64 context_id; /* Context owning resources */
  76. __u64 rsrc_handle; /* Resource handle to release */
  77. __u64 reserved[8]; /* Reserved for future use */
  78. };
  79. struct dk_cxlflash_resize {
  80. struct dk_cxlflash_hdr hdr; /* Common fields */
  81. __u64 context_id; /* Context owning resources */
  82. __u64 rsrc_handle; /* Resource handle of LUN to resize */
  83. __u64 req_size; /* New requested size, in 4K blocks */
  84. __u64 last_lba; /* Returned last LBA of LUN */
  85. __u64 reserved[8]; /* Reserved for future use */
  86. };
  87. struct dk_cxlflash_clone {
  88. struct dk_cxlflash_hdr hdr; /* Common fields */
  89. __u64 context_id_src; /* Context to clone from */
  90. __u64 context_id_dst; /* Context to clone to */
  91. __u64 adap_fd_src; /* Source context adapter fd */
  92. __u64 reserved[8]; /* Reserved for future use */
  93. };
  94. #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
  95. #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
  96. struct dk_cxlflash_verify {
  97. struct dk_cxlflash_hdr hdr; /* Common fields */
  98. __u64 context_id; /* Context owning resources to verify */
  99. __u64 rsrc_handle; /* Resource handle of LUN */
  100. __u64 hint; /* Reasons for verify */
  101. __u64 last_lba; /* Returned last LBA of device */
  102. __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN]; /* SCSI sense data */
  103. __u8 pad[6]; /* Pad to next 8-byte boundary */
  104. __u64 reserved[8]; /* Reserved for future use */
  105. };
  106. #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
  107. struct dk_cxlflash_recover_afu {
  108. struct dk_cxlflash_hdr hdr; /* Common fields */
  109. __u64 reason; /* Reason for recovery request */
  110. __u64 context_id; /* Context to recover / updated ID */
  111. __u64 mmio_size; /* Returned size of MMIO area */
  112. __u64 adap_fd; /* Returned adapter file descriptor */
  113. __u64 reserved[8]; /* Reserved for future use */
  114. };
  115. #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN 16
  116. #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
  117. #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
  118. #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
  119. struct dk_cxlflash_manage_lun {
  120. struct dk_cxlflash_hdr hdr; /* Common fields */
  121. __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN]; /* Page83 WWID, NAA-6 */
  122. __u64 reserved[8]; /* Rsvd, future use */
  123. };
  124. union cxlflash_ioctls {
  125. struct dk_cxlflash_attach attach;
  126. struct dk_cxlflash_detach detach;
  127. struct dk_cxlflash_udirect udirect;
  128. struct dk_cxlflash_uvirtual uvirtual;
  129. struct dk_cxlflash_release release;
  130. struct dk_cxlflash_resize resize;
  131. struct dk_cxlflash_clone clone;
  132. struct dk_cxlflash_verify verify;
  133. struct dk_cxlflash_recover_afu recover_afu;
  134. struct dk_cxlflash_manage_lun manage_lun;
  135. };
  136. #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
  137. #define CXL_MAGIC 0xCA
  138. #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
  139. #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
  140. #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
  141. #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
  142. #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
  143. #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
  144. #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
  145. #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
  146. #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
  147. #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
  148. #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
  149. #endif /* ifndef _CXLFLASH_IOCTL_H */