Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cxl: Move cxl feature command structs to user header

In preparation for cxl fwctl enabling, move data structures related to
cxl feature commands to a user header file.

Reviewed-by; Jonathan Cameron <Jonathan.Cameron@huawei.com>

Link: https://patch.msgid.link/r/20250307205648.1021626-3-dave.jiang@intel.com
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Dave Jiang and committed by
Jason Gunthorpe
9b8e73cd 858ce2f5

+170 -111
+1 -111
include/cxl/features.h
··· 5 5 6 6 #include <linux/uuid.h> 7 7 #include <linux/fwctl.h> 8 + #include <uapi/cxl/features.h> 8 9 9 10 /* Feature UUIDs used by the kernel */ 10 11 #define CXL_FEAT_PATROL_SCRUB_UUID \ ··· 46 45 CXL_FEATURES_RO, 47 46 CXL_FEATURES_RW, 48 47 }; 49 - 50 - /* Get Supported Features (0x500h) CXL r3.2 8.2.9.6.1 */ 51 - struct cxl_mbox_get_sup_feats_in { 52 - __le32 count; 53 - __le16 start_idx; 54 - u8 reserved[2]; 55 - } __packed; 56 - 57 - /* CXL spec r3.2 Table 8-87 command effects */ 58 - #define CXL_CMD_CONFIG_CHANGE_COLD_RESET BIT(0) 59 - #define CXL_CMD_CONFIG_CHANGE_IMMEDIATE BIT(1) 60 - #define CXL_CMD_DATA_CHANGE_IMMEDIATE BIT(2) 61 - #define CXL_CMD_POLICY_CHANGE_IMMEDIATE BIT(3) 62 - #define CXL_CMD_LOG_CHANGE_IMMEDIATE BIT(4) 63 - #define CXL_CMD_SECURITY_STATE_CHANGE BIT(5) 64 - #define CXL_CMD_BACKGROUND BIT(6) 65 - #define CXL_CMD_BGCMD_ABORT_SUPPORTED BIT(7) 66 - #define CXL_CMD_EFFECTS_VALID BIT(9) 67 - #define CXL_CMD_CONFIG_CHANGE_CONV_RESET BIT(10) 68 - #define CXL_CMD_CONFIG_CHANGE_CXL_RESET BIT(11) 69 - 70 - /* 71 - * CXL spec r3.2 Table 8-109 72 - * Get Supported Features Supported Feature Entry 73 - */ 74 - struct cxl_feat_entry { 75 - uuid_t uuid; 76 - __le16 id; 77 - __le16 get_feat_size; 78 - __le16 set_feat_size; 79 - __le32 flags; 80 - u8 get_feat_ver; 81 - u8 set_feat_ver; 82 - __le16 effects; 83 - u8 reserved[18]; 84 - } __packed; 85 - 86 - /* @flags field for 'struct cxl_feat_entry' */ 87 - #define CXL_FEATURE_F_CHANGEABLE BIT(0) 88 - #define CXL_FEATURE_F_PERSIST_FW_UPDATE BIT(4) 89 - #define CXL_FEATURE_F_DEFAULT_SEL BIT(5) 90 - #define CXL_FEATURE_F_SAVED_SEL BIT(6) 91 - 92 - /* 93 - * CXL spec r3.2 Table 8-108 94 - * Get supported Features Output Payload 95 - */ 96 - struct cxl_mbox_get_sup_feats_out { 97 - __struct_group(cxl_mbox_get_sup_feats_out_hdr, hdr, /* no attrs */, 98 - __le16 num_entries; 99 - __le16 supported_feats; 100 - __u8 reserved[4]; 101 - ); 102 - struct cxl_feat_entry ents[] __counted_by_le(num_entries); 103 - } __packed; 104 - 105 - /* 106 - * Get Feature CXL spec r3.2 Spec 8.2.9.6.2 107 - */ 108 - 109 - /* 110 - * Get Feature input payload 111 - * CXL spec r3.2 section 8.2.9.6.2 Table 8-99 112 - */ 113 - struct cxl_mbox_get_feat_in { 114 - uuid_t uuid; 115 - __le16 offset; 116 - __le16 count; 117 - u8 selection; 118 - } __packed; 119 - 120 - /* Selection field for 'struct cxl_mbox_get_feat_in' */ 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 - * Set Feature input payload 134 - * CXL spec r3.2 section 8.2.9.6.3 Table 8-101 135 - */ 136 - struct cxl_mbox_set_feat_in { 137 - __struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */, 138 - uuid_t uuid; 139 - __le32 flags; 140 - __le16 offset; 141 - u8 version; 142 - u8 rsvd[9]; 143 - ); 144 - __u8 feat_data[]; 145 - } __packed; 146 - 147 - /* Set Feature flags field */ 148 - enum cxl_set_feat_flag_data_transfer { 149 - CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER = 0, 150 - CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER, 151 - CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER, 152 - CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER, 153 - CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER, 154 - CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX 155 - }; 156 - 157 - #define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0) 158 - 159 - #define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3) 160 48 161 49 /** 162 50 * struct cxl_features_state - The Features state for the device
+169
include/uapi/cxl/features.h
··· 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