/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */1/*2* Copyright (c) 2024,2025, Intel Corporation3*4* These are definitions for the mailbox command interface of CXL subsystem.5*/6#ifndef _UAPI_CXL_FEATURES_H_7#define _UAPI_CXL_FEATURES_H_89#include <linux/types.h>1011typedef unsigned char __uapi_uuid_t[16];1213#ifdef __KERNEL__14#include <linux/uuid.h>15/*16* Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte17* aligned on others. Ensure that __uapi_uuid_t in a struct is placed at18* a 4-byte aligned offset, or the structure is packed, to ensure19* consistent padding.20*/21static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));22#define __uapi_uuid_t uuid_t23#endif2425/*26* struct cxl_mbox_get_sup_feats_in - Get Supported Features input27*28* @count: bytes of Feature data to return in output29* @start_idx: index of first requested Supported Feature Entry, 0 based.30* @reserved: reserved field, must be 0s.31*32* Get Supported Features (0x500h) CXL r3.2 8.2.9.6.1 command.33* Input block for Get support Feature34*/35struct cxl_mbox_get_sup_feats_in {36__le32 count;37__le16 start_idx;38__u8 reserved[2];39} __attribute__ ((__packed__));4041/* CXL spec r3.2 Table 8-87 command effects */42#define CXL_CMD_CONFIG_CHANGE_COLD_RESET BIT(0)43#define CXL_CMD_CONFIG_CHANGE_IMMEDIATE BIT(1)44#define CXL_CMD_DATA_CHANGE_IMMEDIATE BIT(2)45#define CXL_CMD_POLICY_CHANGE_IMMEDIATE BIT(3)46#define CXL_CMD_LOG_CHANGE_IMMEDIATE BIT(4)47#define CXL_CMD_SECURITY_STATE_CHANGE BIT(5)48#define CXL_CMD_BACKGROUND BIT(6)49#define CXL_CMD_BGCMD_ABORT_SUPPORTED BIT(7)50#define CXL_CMD_EFFECTS_VALID BIT(9)51#define CXL_CMD_CONFIG_CHANGE_CONV_RESET BIT(10)52#define CXL_CMD_CONFIG_CHANGE_CXL_RESET BIT(11)53#define CXL_CMD_EFFECTS_RESERVED GENMASK(15, 12)5455/*56* struct cxl_feat_entry - Supported Feature Entry57* @uuid: UUID of the Feature58* @id: id to identify the feature. 0 based59* @get_feat_size: max bytes required for Get Feature command for this Feature60* @set_feat_size: max bytes required for Set Feature command for this Feature61* @flags: attribute flags62* @get_feat_ver: Get Feature version63* @set_feat_ver: Set Feature version64* @effects: Set Feature command effects65* @reserved: reserved, must be 066*67* CXL spec r3.2 Table 8-10968* Get Supported Features Supported Feature Entry69*/70struct cxl_feat_entry {71__uapi_uuid_t uuid;72__le16 id;73__le16 get_feat_size;74__le16 set_feat_size;75__le32 flags;76__u8 get_feat_ver;77__u8 set_feat_ver;78__le16 effects;79__u8 reserved[18];80} __attribute__ ((__packed__));8182/* @flags field for 'struct cxl_feat_entry' */83#define CXL_FEATURE_F_CHANGEABLE BIT(0)84#define CXL_FEATURE_F_PERSIST_FW_UPDATE BIT(4)85#define CXL_FEATURE_F_DEFAULT_SEL BIT(5)86#define CXL_FEATURE_F_SAVED_SEL BIT(6)8788/*89* struct cxl_mbox_get_sup_feats_out - Get Supported Features output90* @num_entries: number of Supported Feature Entries returned91* @supported_feats: number of supported Features92* @reserved: reserved, must be 0s.93* @ents: Supported Feature Entries array94*95* CXL spec r3.2 Table 8-10896* Get supported Features Output Payload97*/98struct cxl_mbox_get_sup_feats_out {99__struct_group(cxl_mbox_get_sup_feats_out_hdr, hdr, /* no attrs */,100__le16 num_entries;101__le16 supported_feats;102__u8 reserved[4];103);104struct cxl_feat_entry ents[] __counted_by_le(num_entries);105} __attribute__ ((__packed__));106107/*108* Get Feature CXL spec r3.2 Spec 8.2.9.6.2109*/110111/*112* struct cxl_mbox_get_feat_in - Get Feature input113* @uuid: UUID for Feature114* @offset: offset of the first byte in Feature data for output payload115* @count: count in bytes of Feature data returned116* @selection: 0 current value, 1 default value, 2 saved value117*118* CXL spec r3.2 section 8.2.9.6.2 Table 8-99119*/120struct cxl_mbox_get_feat_in {121__uapi_uuid_t uuid;122__le16 offset;123__le16 count;124__u8 selection;125} __attribute__ ((__packed__));126127/*128* enum cxl_get_feat_selection - selection field of Get Feature input129*/130enum cxl_get_feat_selection {131CXL_GET_FEAT_SEL_CURRENT_VALUE,132CXL_GET_FEAT_SEL_DEFAULT_VALUE,133CXL_GET_FEAT_SEL_SAVED_VALUE,134CXL_GET_FEAT_SEL_MAX135};136137/*138* Set Feature CXL spec r3.2 8.2.9.6.3139*/140141/*142* struct cxl_mbox_set_feat_in - Set Features input143* @uuid: UUID for Feature144* @flags: set feature flags145* @offset: byte offset of Feature data to update146* @version: Feature version of the data in Feature Data147* @rsvd: reserved, must be 0s.148* @feat_data: raw byte stream of Features data to update149*150* CXL spec r3.2 section 8.2.9.6.3 Table 8-101151*/152struct cxl_mbox_set_feat_in {153__struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,154__uapi_uuid_t uuid;155__le32 flags;156__le16 offset;157__u8 version;158__u8 rsvd[9];159);160__u8 feat_data[];161} __packed;162163/*164* enum cxl_set_feat_flag_data_transfer - Set Feature flags field165*/166enum cxl_set_feat_flag_data_transfer {167CXL_SET_FEAT_FLAG_FULL_DATA_TRANSFER = 0,168CXL_SET_FEAT_FLAG_INITIATE_DATA_TRANSFER,169CXL_SET_FEAT_FLAG_CONTINUE_DATA_TRANSFER,170CXL_SET_FEAT_FLAG_FINISH_DATA_TRANSFER,171CXL_SET_FEAT_FLAG_ABORT_DATA_TRANSFER,172CXL_SET_FEAT_FLAG_DATA_TRANSFER_MAX173};174175#define CXL_SET_FEAT_FLAG_DATA_TRANSFER_MASK GENMASK(2, 0)176#define CXL_SET_FEAT_FLAG_DATA_SAVED_ACROSS_RESET BIT(3)177178#endif179180181