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