cxl.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_ALL (CXL_START_WORK_AMR |\
  28. CXL_START_WORK_NUM_IRQS)
  29. /* Possible modes that an afu can be in */
  30. #define CXL_MODE_DEDICATED 0x1
  31. #define CXL_MODE_DIRECTED 0x2
  32. /* possible flags for the cxl_afu_id flags field */
  33. #define CXL_AFUID_FLAG_SLAVE 0x1 /* In directed-mode afu is in slave mode */
  34. struct cxl_afu_id {
  35. __u64 flags; /* One of CXL_AFUID_FLAG_X */
  36. __u32 card_id;
  37. __u32 afu_offset;
  38. __u32 afu_mode; /* one of the CXL_MODE_X */
  39. __u32 reserved1;
  40. __u64 reserved2;
  41. __u64 reserved3;
  42. __u64 reserved4;
  43. __u64 reserved5;
  44. __u64 reserved6;
  45. };
  46. /* ioctl numbers */
  47. #define CXL_MAGIC 0xCA
  48. #define CXL_IOCTL_START_WORK _IOW(CXL_MAGIC, 0x00, struct cxl_ioctl_start_work)
  49. #define CXL_IOCTL_GET_PROCESS_ELEMENT _IOR(CXL_MAGIC, 0x01, __u32)
  50. #define CXL_IOCTL_GET_AFU_ID _IOR(CXL_MAGIC, 0x02, struct cxl_afu_id)
  51. #define CXL_READ_MIN_SIZE 0x1000 /* 4K */
  52. /* Events from read() */
  53. enum cxl_event_type {
  54. CXL_EVENT_RESERVED = 0,
  55. CXL_EVENT_AFU_INTERRUPT = 1,
  56. CXL_EVENT_DATA_STORAGE = 2,
  57. CXL_EVENT_AFU_ERROR = 3,
  58. };
  59. struct cxl_event_header {
  60. __u16 type;
  61. __u16 size;
  62. __u16 process_element;
  63. __u16 reserved1;
  64. };
  65. struct cxl_event_afu_interrupt {
  66. __u16 flags;
  67. __u16 irq; /* Raised AFU interrupt number */
  68. __u32 reserved1;
  69. };
  70. struct cxl_event_data_storage {
  71. __u16 flags;
  72. __u16 reserved1;
  73. __u32 reserved2;
  74. __u64 addr;
  75. __u64 dsisr;
  76. __u64 reserved3;
  77. };
  78. struct cxl_event_afu_error {
  79. __u16 flags;
  80. __u16 reserved1;
  81. __u32 reserved2;
  82. __u64 error;
  83. };
  84. struct cxl_event {
  85. struct cxl_event_header header;
  86. union {
  87. struct cxl_event_afu_interrupt irq;
  88. struct cxl_event_data_storage fault;
  89. struct cxl_event_afu_error afu_error;
  90. };
  91. };
  92. #endif /* _UAPI_MISC_CXL_H */