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