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