features.h 4.7 KB

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