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 #define CXL_CMD_EFFECTS_RESERVED GENMASK(15, 12) 46 47 /* 48 * struct cxl_feat_entry - Supported Feature Entry 49 * @uuid: UUID of the Feature 50 * @id: id to identify the feature. 0 based 51 * @get_feat_size: max bytes required for Get Feature command for this Feature 52 * @set_feat_size: max bytes required for Set Feature command for this Feature 53 * @flags: attribute flags 54 * @get_feat_ver: Get Feature version 55 * @set_feat_ver: Set Feature version 56 * @effects: Set Feature command effects 57 * @reserved: reserved, must be 0 58 * 59 * CXL spec r3.2 Table 8-109 60 * Get Supported Features Supported Feature Entry 61 */ 62 struct cxl_feat_entry { 63 uuid_t uuid; 64 __le16 id; 65 __le16 get_feat_size; 66 __le16 set_feat_size; 67 __le32 flags; 68 __u8 get_feat_ver; 69 __u8 set_feat_ver; 70 __le16 effects; 71 __u8 reserved[18]; 72 } __attribute__ ((__packed__)); 73 74 /* @flags field for 'struct cxl_feat_entry' */ 75 #define CXL_FEATURE_F_CHANGEABLE BIT(0) 76 #define CXL_FEATURE_F_PERSIST_FW_UPDATE BIT(4) 77 #define CXL_FEATURE_F_DEFAULT_SEL BIT(5) 78 #define CXL_FEATURE_F_SAVED_SEL BIT(6) 79 80 /* 81 * struct cxl_mbox_get_sup_feats_out - Get Supported Features output 82 * @num_entries: number of Supported Feature Entries returned 83 * @supported_feats: number of supported Features 84 * @reserved: reserved, must be 0s. 85 * @ents: Supported Feature Entries array 86 * 87 * CXL spec r3.2 Table 8-108 88 * Get supported Features Output Payload 89 */ 90 struct cxl_mbox_get_sup_feats_out { 91 __struct_group(cxl_mbox_get_sup_feats_out_hdr, hdr, /* no attrs */, 92 __le16 num_entries; 93 __le16 supported_feats; 94 __u8 reserved[4]; 95 ); 96 struct cxl_feat_entry ents[] __counted_by_le(num_entries); 97 } __attribute__ ((__packed__)); 98 99 /* 100 * Get Feature CXL spec r3.2 Spec 8.2.9.6.2 101 */ 102 103 /* 104 * struct cxl_mbox_get_feat_in - Get Feature input 105 * @uuid: UUID for Feature 106 * @offset: offset of the first byte in Feature data for output payload 107 * @count: count in bytes of Feature data returned 108 * @selection: 0 current value, 1 default value, 2 saved value 109 * 110 * CXL spec r3.2 section 8.2.9.6.2 Table 8-99 111 */ 112 struct cxl_mbox_get_feat_in { 113 uuid_t uuid; 114 __le16 offset; 115 __le16 count; 116 __u8 selection; 117 } __attribute__ ((__packed__)); 118 119 /* 120 * enum cxl_get_feat_selection - selection field of Get Feature input 121 */ 122 enum cxl_get_feat_selection { 123 CXL_GET_FEAT_SEL_CURRENT_VALUE, 124 CXL_GET_FEAT_SEL_DEFAULT_VALUE, 125 CXL_GET_FEAT_SEL_SAVED_VALUE, 126 CXL_GET_FEAT_SEL_MAX 127 }; 128 129 /* 130 * Set Feature CXL spec r3.2 8.2.9.6.3 131 */ 132 133 /* 134 * struct cxl_mbox_set_feat_in - Set Features input 135 * @uuid: UUID for Feature 136 * @flags: set feature flags 137 * @offset: byte offset of Feature data to update 138 * @version: Feature version of the data in Feature Data 139 * @rsvd: reserved, must be 0s. 140 * @feat_data: raw byte stream of Features data to update 141 * 142 * CXL spec r3.2 section 8.2.9.6.3 Table 8-101 143 */ 144 struct cxl_mbox_set_feat_in { 145 __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */, 146 uuid_t uuid; 147 __le32 flags; 148 __le16 offset; 149 __u8 version; 150 __u8 rsvd[9]; 151 ); 152 __u8 feat_data[]; 153 } __packed; 154 155 /* 156 * enum cxl_set_feat_flag_data_transfer - Set Feature flags field 157 */ 158 enum cxl_set_feat_flag_data_transfer { 159 CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER = 0, 160 CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER, 161 CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER, 162 CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER, 163 CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER, 164 CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX 165 }; 166 167 #define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) 168 #define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) 169 170 #endif 171