features.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2024,2025, Intel Corporation
  4. *
  5. * These are definitions for the mailbox command interface of CXL subsystem.
  6. */
  7. #ifndef _UAPI_CXL_FEATURES_H_
  8. #define _UAPI_CXL_FEATURES_H_
  9. #include <linux/types.h>
  10. typedef unsigned char __uapi_uuid_t[16];
  11. #ifdef __KERNEL__
  12. #include <linux/uuid.h>
  13. /*
  14. * Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte
  15. * aligned on others. Ensure that __uapi_uuid_t in a struct is placed at
  16. * a 4-byte aligned offset, or the structure is packed, to ensure
  17. * consistent padding.
  18. */
  19. static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));
  20. #define __uapi_uuid_t uuid_t
  21. #endif
  22. /*
  23. * struct cxl_mbox_get_sup_feats_in - Get Supported Features input
  24. *
  25. * @count: bytes of Feature data to return in output
  26. * @start_idx: index of first requested Supported Feature Entry, 0 based.
  27. * @reserved: reserved field, must be 0s.
  28. *
  29. * Get Supported Features (0x500h) CXL r3.2 8.2.9.6.1 command.
  30. * Input block for Get support Feature
  31. */
  32. struct cxl_mbox_get_sup_feats_in {
  33. __le32 count;
  34. __le16 start_idx;
  35. __u8 reserved[2];
  36. } __attribute__ ((__packed__));
  37. /* CXL spec r3.2 Table 8-87 command effects */
  38. #define CXL_CMD_CONFIG_CHANGE_COLD_RESET BIT(0)
  39. #define CXL_CMD_CONFIG_CHANGE_IMMEDIATE BIT(1)
  40. #define CXL_CMD_DATA_CHANGE_IMMEDIATE BIT(2)
  41. #define CXL_CMD_POLICY_CHANGE_IMMEDIATE BIT(3)
  42. #define CXL_CMD_LOG_CHANGE_IMMEDIATE BIT(4)
  43. #define CXL_CMD_SECURITY_STATE_CHANGE BIT(5)
  44. #define CXL_CMD_BACKGROUND BIT(6)
  45. #define CXL_CMD_BGCMD_ABORT_SUPPORTED BIT(7)
  46. #define CXL_CMD_EFFECTS_VALID BIT(9)
  47. #define CXL_CMD_CONFIG_CHANGE_CONV_RESET BIT(10)
  48. #define CXL_CMD_CONFIG_CHANGE_CXL_RESET BIT(11)
  49. #define CXL_CMD_EFFECTS_RESERVED GENMASK(15, 12)
  50. /*
  51. * struct cxl_feat_entry - Supported Feature Entry
  52. * @uuid: UUID of the Feature
  53. * @id: id to identify the feature. 0 based
  54. * @get_feat_size: max bytes required for Get Feature command for this Feature
  55. * @set_feat_size: max bytes required for Set Feature command for this Feature
  56. * @flags: attribute flags
  57. * @get_feat_ver: Get Feature version
  58. * @set_feat_ver: Set Feature version
  59. * @effects: Set Feature command effects
  60. * @reserved: reserved, must be 0
  61. *
  62. * CXL spec r3.2 Table 8-109
  63. * Get Supported Features Supported Feature Entry
  64. */
  65. struct cxl_feat_entry {
  66. __uapi_uuid_t uuid;
  67. __le16 id;
  68. __le16 get_feat_size;
  69. __le16 set_feat_size;
  70. __le32 flags;
  71. __u8 get_feat_ver;
  72. __u8 set_feat_ver;
  73. __le16 effects;
  74. __u8 reserved[18];
  75. } __attribute__ ((__packed__));
  76. /* @flags field for 'struct cxl_feat_entry' */
  77. #define CXL_FEATURE_F_CHANGEABLE BIT(0)
  78. #define CXL_FEATURE_F_PERSIST_FW_UPDATE BIT(4)
  79. #define CXL_FEATURE_F_DEFAULT_SEL BIT(5)
  80. #define CXL_FEATURE_F_SAVED_SEL BIT(6)
  81. /*
  82. * struct cxl_mbox_get_sup_feats_out - Get Supported Features output
  83. * @num_entries: number of Supported Feature Entries returned
  84. * @supported_feats: number of supported Features
  85. * @reserved: reserved, must be 0s.
  86. * @ents: Supported Feature Entries array
  87. *
  88. * CXL spec r3.2 Table 8-108
  89. * Get supported Features Output Payload
  90. */
  91. struct cxl_mbox_get_sup_feats_out {
  92. __struct_group(cxl_mbox_get_sup_feats_out_hdr, hdr, /* no attrs */,
  93. __le16 num_entries;
  94. __le16 supported_feats;
  95. __u8 reserved[4];
  96. );
  97. struct cxl_feat_entry ents[] __counted_by_le(num_entries);
  98. } __attribute__ ((__packed__));
  99. /*
  100. * Get Feature CXL spec r3.2 Spec 8.2.9.6.2
  101. */
  102. /*
  103. * struct cxl_mbox_get_feat_in - Get Feature input
  104. * @uuid: UUID for Feature
  105. * @offset: offset of the first byte in Feature data for output payload
  106. * @count: count in bytes of Feature data returned
  107. * @selection: 0 current value, 1 default value, 2 saved value
  108. *
  109. * CXL spec r3.2 section 8.2.9.6.2 Table 8-99
  110. */
  111. struct cxl_mbox_get_feat_in {
  112. __uapi_uuid_t uuid;
  113. __le16 offset;
  114. __le16 count;
  115. __u8 selection;
  116. } __attribute__ ((__packed__));
  117. /*
  118. * enum cxl_get_feat_selection - selection field of Get Feature input
  119. */
  120. enum cxl_get_feat_selection {
  121. CXL_GET_FEAT_SEL_CURRENT_VALUE,
  122. CXL_GET_FEAT_SEL_DEFAULT_VALUE,
  123. CXL_GET_FEAT_SEL_SAVED_VALUE,
  124. CXL_GET_FEAT_SEL_MAX
  125. };
  126. /*
  127. * Set Feature CXL spec r3.2 8.2.9.6.3
  128. */
  129. /*
  130. * struct cxl_mbox_set_feat_in - Set Features input
  131. * @uuid: UUID for Feature
  132. * @flags: set feature flags
  133. * @offset: byte offset of Feature data to update
  134. * @version: Feature version of the data in Feature Data
  135. * @rsvd: reserved, must be 0s.
  136. * @feat_data: raw byte stream of Features data to update
  137. *
  138. * CXL spec r3.2 section 8.2.9.6.3 Table 8-101
  139. */
  140. struct cxl_mbox_set_feat_in {
  141. __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
  142. __uapi_uuid_t uuid;
  143. __le32 flags;
  144. __le16 offset;
  145. __u8 version;
  146. __u8 rsvd[9];
  147. );
  148. __u8 feat_data[];
  149. } __packed;
  150. /*
  151. * enum cxl_set_feat_flag_data_transfer - Set Feature flags field
  152. */
  153. enum cxl_set_feat_flag_data_transfer {
  154. CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER = 0,
  155. CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER,
  156. CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER,
  157. CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER,
  158. CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER,
  159. CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX
  160. };
  161. #define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0)
  162. #define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3)
  163. #endif