Skip to content

Commit 9b8e73c

Browse files
davejiangjgunthorpe
authored andcommitted
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 <[email protected]> Link: https://patch.msgid.link/r/[email protected] Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Li Ming <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 858ce2f commit 9b8e73c

File tree

2 files changed

+170
-111
lines changed

2 files changed

+170
-111
lines changed

include/cxl/features.h

Lines changed: 1 addition & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/uuid.h>
77
#include <linux/fwctl.h>
8+
#include <uapi/cxl/features.h>
89

910
/* Feature UUIDs used by the kernel */
1011
#define CXL_FEAT_PATROL_SCRUB_UUID \
@@ -46,117 +47,6 @@ enum cxl_features_capability {
4647
CXL_FEATURES_RW,
4748
};
4849

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

include/uapi/cxl/features.h

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
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

0 commit comments

Comments
 (0)