![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * CXL IOCTLs for Memory Devices 0004 */ 0005 0006 #ifndef _UAPI_CXL_MEM_H_ 0007 #define _UAPI_CXL_MEM_H_ 0008 0009 #include <linux/types.h> 0010 0011 /** 0012 * DOC: UAPI 0013 * 0014 * Not all of all commands that the driver supports are always available for use 0015 * by userspace. Userspace must check the results from the QUERY command in 0016 * order to determine the live set of commands. 0017 */ 0018 0019 #define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands) 0020 #define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command) 0021 0022 #define CXL_CMDS \ 0023 ___C(INVALID, "Invalid Command"), \ 0024 ___C(IDENTIFY, "Identify Command"), \ 0025 ___C(RAW, "Raw device command"), \ 0026 ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), \ 0027 ___C(GET_FW_INFO, "Get FW Info"), \ 0028 ___C(GET_PARTITION_INFO, "Get Partition Information"), \ 0029 ___C(GET_LSA, "Get Label Storage Area"), \ 0030 ___C(GET_HEALTH_INFO, "Get Health Info"), \ 0031 ___C(GET_LOG, "Get Log"), \ 0032 ___C(SET_PARTITION_INFO, "Set Partition Information"), \ 0033 ___C(SET_LSA, "Set Label Storage Area"), \ 0034 ___C(GET_ALERT_CONFIG, "Get Alert Configuration"), \ 0035 ___C(SET_ALERT_CONFIG, "Set Alert Configuration"), \ 0036 ___C(GET_SHUTDOWN_STATE, "Get Shutdown State"), \ 0037 ___C(SET_SHUTDOWN_STATE, "Set Shutdown State"), \ 0038 ___C(GET_POISON, "Get Poison List"), \ 0039 ___C(INJECT_POISON, "Inject Poison"), \ 0040 ___C(CLEAR_POISON, "Clear Poison"), \ 0041 ___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"), \ 0042 ___C(SCAN_MEDIA, "Scan Media"), \ 0043 ___C(GET_SCAN_MEDIA, "Get Scan Media Results"), \ 0044 ___C(MAX, "invalid / last command") 0045 0046 #define ___C(a, b) CXL_MEM_COMMAND_ID_##a 0047 enum { CXL_CMDS }; 0048 0049 #undef ___C 0050 #define ___C(a, b) { b } 0051 static const struct { 0052 const char *name; 0053 } cxl_command_names[] __attribute__((__unused__)) = { CXL_CMDS }; 0054 0055 /* 0056 * Here's how this actually breaks out: 0057 * cxl_command_names[] = { 0058 * [CXL_MEM_COMMAND_ID_INVALID] = { "Invalid Command" }, 0059 * [CXL_MEM_COMMAND_ID_IDENTIFY] = { "Identify Command" }, 0060 * ... 0061 * [CXL_MEM_COMMAND_ID_MAX] = { "invalid / last command" }, 0062 * }; 0063 */ 0064 0065 #undef ___C 0066 0067 /** 0068 * struct cxl_command_info - Command information returned from a query. 0069 * @id: ID number for the command. 0070 * @flags: Flags that specify command behavior. 0071 * @size_in: Expected input size, or ~0 if variable length. 0072 * @size_out: Expected output size, or ~0 if variable length. 0073 * 0074 * Represents a single command that is supported by both the driver and the 0075 * hardware. This is returned as part of an array from the query ioctl. The 0076 * following would be a command that takes a variable length input and returns 0 0077 * bytes of output. 0078 * 0079 * - @id = 10 0080 * - @flags = 0 0081 * - @size_in = ~0 0082 * - @size_out = 0 0083 * 0084 * See struct cxl_mem_query_commands. 0085 */ 0086 struct cxl_command_info { 0087 __u32 id; 0088 0089 __u32 flags; 0090 #define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0) 0091 0092 __u32 size_in; 0093 __u32 size_out; 0094 }; 0095 0096 /** 0097 * struct cxl_mem_query_commands - Query supported commands. 0098 * @n_commands: In/out parameter. When @n_commands is > 0, the driver will 0099 * return min(num_support_commands, n_commands). When @n_commands 0100 * is 0, driver will return the number of total supported commands. 0101 * @rsvd: Reserved for future use. 0102 * @commands: Output array of supported commands. This array must be allocated 0103 * by userspace to be at least min(num_support_commands, @n_commands) 0104 * 0105 * Allow userspace to query the available commands supported by both the driver, 0106 * and the hardware. Commands that aren't supported by either the driver, or the 0107 * hardware are not returned in the query. 0108 * 0109 * Examples: 0110 * 0111 * - { .n_commands = 0 } // Get number of supported commands 0112 * - { .n_commands = 15, .commands = buf } // Return first 15 (or less) 0113 * supported commands 0114 * 0115 * See struct cxl_command_info. 0116 */ 0117 struct cxl_mem_query_commands { 0118 /* 0119 * Input: Number of commands to return (space allocated by user) 0120 * Output: Number of commands supported by the driver/hardware 0121 * 0122 * If n_commands is 0, kernel will only return number of commands and 0123 * not try to populate commands[], thus allowing userspace to know how 0124 * much space to allocate 0125 */ 0126 __u32 n_commands; 0127 __u32 rsvd; 0128 0129 struct cxl_command_info __user commands[]; /* out: supported commands */ 0130 }; 0131 0132 /** 0133 * struct cxl_send_command - Send a command to a memory device. 0134 * @id: The command to send to the memory device. This must be one of the 0135 * commands returned by the query command. 0136 * @flags: Flags for the command (input). 0137 * @raw: Special fields for raw commands 0138 * @raw.opcode: Opcode passed to hardware when using the RAW command. 0139 * @raw.rsvd: Must be zero. 0140 * @rsvd: Must be zero. 0141 * @retval: Return value from the memory device (output). 0142 * @in: Parameters associated with input payload. 0143 * @in.size: Size of the payload to provide to the device (input). 0144 * @in.rsvd: Must be zero. 0145 * @in.payload: Pointer to memory for payload input, payload is little endian. 0146 * @out: Parameters associated with output payload. 0147 * @out.size: Size of the payload received from the device (input/output). This 0148 * field is filled in by userspace to let the driver know how much 0149 * space was allocated for output. It is populated by the driver to 0150 * let userspace know how large the output payload actually was. 0151 * @out.rsvd: Must be zero. 0152 * @out.payload: Pointer to memory for payload output, payload is little endian. 0153 * 0154 * Mechanism for userspace to send a command to the hardware for processing. The 0155 * driver will do basic validation on the command sizes. In some cases even the 0156 * payload may be introspected. Userspace is required to allocate large enough 0157 * buffers for size_out which can be variable length in certain situations. 0158 */ 0159 struct cxl_send_command { 0160 __u32 id; 0161 __u32 flags; 0162 union { 0163 struct { 0164 __u16 opcode; 0165 __u16 rsvd; 0166 } raw; 0167 __u32 rsvd; 0168 }; 0169 __u32 retval; 0170 0171 struct { 0172 __u32 size; 0173 __u32 rsvd; 0174 __u64 payload; 0175 } in; 0176 0177 struct { 0178 __u32 size; 0179 __u32 rsvd; 0180 __u64 payload; 0181 } out; 0182 }; 0183 0184 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |