Skip to content

Commit 49be6dd

Browse files
committed
cxl/mbox: Move command definitions to common location
In preparation for cxl_test to mock responses to mailbox command requests, move some definitions from core/mbox.c to cxlmem.h. No functional changes intended. Acked-by: Ben Widawsky <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/163116439547.2460985.10457111177103589574.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <[email protected]>
1 parent a5c2580 commit 49be6dd

File tree

3 files changed

+65
-48
lines changed

3 files changed

+65
-48
lines changed

drivers/cxl/core/mbox.c

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,7 @@ static int cxl_xfer_log(struct cxl_mem *cxlm, uuid_t *uuid, u32 size, u8 *out)
485485

486486
while (remaining) {
487487
u32 xfer_size = min_t(u32, remaining, cxlm->payload_size);
488-
struct cxl_mbox_get_log {
489-
uuid_t uuid;
490-
__le32 offset;
491-
__le32 length;
492-
} __packed log = {
488+
struct cxl_mbox_get_log log = {
493489
.uuid = *uuid,
494490
.offset = cpu_to_le32(offset),
495491
.length = cpu_to_le32(xfer_size)
@@ -520,14 +516,11 @@ static int cxl_xfer_log(struct cxl_mem *cxlm, uuid_t *uuid, u32 size, u8 *out)
520516
*/
521517
static void cxl_walk_cel(struct cxl_mem *cxlm, size_t size, u8 *cel)
522518
{
523-
struct cel_entry {
524-
__le16 opcode;
525-
__le16 effect;
526-
} __packed * cel_entry;
519+
struct cxl_cel_entry *cel_entry;
527520
const int cel_entries = size / sizeof(*cel_entry);
528521
int i;
529522

530-
cel_entry = (struct cel_entry *)cel;
523+
cel_entry = (struct cxl_cel_entry *) cel;
531524

532525
for (i = 0; i < cel_entries; i++) {
533526
u16 opcode = le16_to_cpu(cel_entry[i].opcode);
@@ -543,15 +536,6 @@ static void cxl_walk_cel(struct cxl_mem *cxlm, size_t size, u8 *cel)
543536
}
544537
}
545538

546-
struct cxl_mbox_get_supported_logs {
547-
__le16 entries;
548-
u8 rsvd[6];
549-
struct gsl_entry {
550-
uuid_t uuid;
551-
__le32 size;
552-
} __packed entry[];
553-
} __packed;
554-
555539
static struct cxl_mbox_get_supported_logs *cxl_get_gsl(struct cxl_mem *cxlm)
556540
{
557541
struct cxl_mbox_get_supported_logs *ret;
@@ -578,10 +562,8 @@ enum {
578562

579563
/* See CXL 2.0 Table 170. Get Log Input Payload */
580564
static const uuid_t log_uuid[] = {
581-
[CEL_UUID] = UUID_INIT(0xda9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79, 0x96,
582-
0xb1, 0x62, 0x3b, 0x3f, 0x17),
583-
[VENDOR_DEBUG_UUID] = UUID_INIT(0xe1819d9, 0x11a9, 0x400c, 0x81, 0x1f,
584-
0xd6, 0x07, 0x19, 0x40, 0x3d, 0x86),
565+
[CEL_UUID] = DEFINE_CXL_CEL_UUID,
566+
[VENDOR_DEBUG_UUID] = DEFINE_CXL_VENDOR_DEBUG_UUID,
585567
};
586568

587569
/**
@@ -698,22 +680,7 @@ static int cxl_mem_get_partition_info(struct cxl_mem *cxlm)
698680
int cxl_mem_identify(struct cxl_mem *cxlm)
699681
{
700682
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
701-
struct cxl_mbox_identify {
702-
char fw_revision[0x10];
703-
__le64 total_capacity;
704-
__le64 volatile_capacity;
705-
__le64 persistent_capacity;
706-
__le64 partition_align;
707-
__le16 info_event_log_size;
708-
__le16 warning_event_log_size;
709-
__le16 failure_event_log_size;
710-
__le16 fatal_event_log_size;
711-
__le32 lsa_size;
712-
u8 poison_list_max_mer[3];
713-
__le16 inject_poison_limit;
714-
u8 poison_caps;
715-
u8 qos_telemetry_caps;
716-
} __packed id;
683+
struct cxl_mbox_identify id;
717684
int rc;
718685

719686
rc = cxl_mem_mbox_send_cmd(cxlm, CXL_MBOX_OP_IDENTIFY, NULL, 0, &id,

drivers/cxl/cxlmem.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,63 @@ enum cxl_opcode {
171171
CXL_MBOX_OP_MAX = 0x10000
172172
};
173173

174+
#define DEFINE_CXL_CEL_UUID \
175+
UUID_INIT(0xda9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79, 0x96, 0xb1, 0x62, \
176+
0x3b, 0x3f, 0x17)
177+
178+
#define DEFINE_CXL_VENDOR_DEBUG_UUID \
179+
UUID_INIT(0xe1819d9, 0x11a9, 0x400c, 0x81, 0x1f, 0xd6, 0x07, 0x19, \
180+
0x40, 0x3d, 0x86)
181+
182+
struct cxl_mbox_get_supported_logs {
183+
__le16 entries;
184+
u8 rsvd[6];
185+
struct cxl_gsl_entry {
186+
uuid_t uuid;
187+
__le32 size;
188+
} __packed entry[];
189+
} __packed;
190+
191+
struct cxl_cel_entry {
192+
__le16 opcode;
193+
__le16 effect;
194+
} __packed;
195+
196+
struct cxl_mbox_get_log {
197+
uuid_t uuid;
198+
__le32 offset;
199+
__le32 length;
200+
} __packed;
201+
202+
/* See CXL 2.0 Table 175 Identify Memory Device Output Payload */
203+
struct cxl_mbox_identify {
204+
char fw_revision[0x10];
205+
__le64 total_capacity;
206+
__le64 volatile_capacity;
207+
__le64 persistent_capacity;
208+
__le64 partition_align;
209+
__le16 info_event_log_size;
210+
__le16 warning_event_log_size;
211+
__le16 failure_event_log_size;
212+
__le16 fatal_event_log_size;
213+
__le32 lsa_size;
214+
u8 poison_list_max_mer[3];
215+
__le16 inject_poison_limit;
216+
u8 poison_caps;
217+
u8 qos_telemetry_caps;
218+
} __packed;
219+
220+
struct cxl_mbox_get_lsa {
221+
u32 offset;
222+
u32 length;
223+
} __packed;
224+
225+
struct cxl_mbox_set_lsa {
226+
u32 offset;
227+
u32 reserved;
228+
u8 data[];
229+
} __packed;
230+
174231
/**
175232
* struct cxl_mem_command - Driver representation of a memory device command
176233
* @info: Command information as it exists for the UAPI

drivers/cxl/pmem.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ static int cxl_pmem_get_config_data(struct cxl_mem *cxlm,
9999
struct nd_cmd_get_config_data_hdr *cmd,
100100
unsigned int buf_len)
101101
{
102-
struct cxl_mbox_get_lsa {
103-
u32 offset;
104-
u32 length;
105-
} get_lsa;
102+
struct cxl_mbox_get_lsa get_lsa;
106103
int rc;
107104

108105
if (sizeof(*cmd) > buf_len)
@@ -127,11 +124,7 @@ static int cxl_pmem_set_config_data(struct cxl_mem *cxlm,
127124
struct nd_cmd_set_config_hdr *cmd,
128125
unsigned int buf_len)
129126
{
130-
struct cxl_mbox_set_lsa {
131-
u32 offset;
132-
u32 reserved;
133-
u8 data[];
134-
} *set_lsa;
127+
struct cxl_mbox_set_lsa *set_lsa;
135128
int rc;
136129

137130
if (sizeof(*cmd) > buf_len)

0 commit comments

Comments
 (0)