cxl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. /* ioctl numbers */
  49. #define CXL_MAGIC 0xCA
  50. #define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
  51. #define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
  52. #define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
  53. #define CXL_READ_MIN_SIZE 0x1000 /* 4K */
  54. /* Events from read() */
  55. enum cxl_event_type {
  56. CXL_EVENT_RESERVED = 0,
  57. CXL_EVENT_AFU_INTERRUPT = 1,
  58. CXL_EVENT_DATA_STORAGE = 2,
  59. CXL_EVENT_AFU_ERROR = 3,
  60. };
  61. struct cxl_event_header {
  62. __u16 type;
  63. __u16 size;
  64. __u16 process_element;
  65. __u16 reserved1;
  66. };
  67. struct cxl_event_afu_interrupt {
  68. __u16 flags;
  69. __u16 irq; /* Raised AFU interrupt number */
  70. __u32 reserved1;
  71. };
  72. struct cxl_event_data_storage {
  73. __u16 flags;
  74. __u16 reserved1;
  75. __u32 reserved2;
  76. __u64 addr;
  77. __u64 dsisr;
  78. __u64 reserved3;
  79. };
  80. struct cxl_event_afu_error {
  81. __u16 flags;
  82. __u16 reserved1;
  83. __u32 reserved2;
  84. __u64 error;
  85. };
  86. struct cxl_event {
  87. struct cxl_event_header header;
  88. union {
  89. struct cxl_event_afu_interrupt irq;
  90. struct cxl_event_data_storage fault;
  91. struct cxl_event_afu_error afu_error;
  92. };
  93. };
  94. #endif /* _UAPI_MISC_CXL_H */