Loading...
1/*
2 * Copyright 2015 IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#ifndef _HCALLS_H
11#define _HCALLS_H
12
13#include <linux/types.h>
14#include <asm/byteorder.h>
15#include <asm/hvcall.h>
16#include "cxl.h"
17
18#define SG_BUFFER_SIZE 4096
19#define SG_MAX_ENTRIES 256
20
21struct sg_list {
22 u64 phys_addr;
23 u64 len;
24};
25
26/*
27 * This is straight out of PAPR, but replacing some of the compound fields with
28 * a single field, where they were identical to the register layout.
29 *
30 * The 'flags' parameter regroups the various bit-fields
31 */
32#define CXL_PE_CSRP_VALID (1ULL << 63)
33#define CXL_PE_PROBLEM_STATE (1ULL << 62)
34#define CXL_PE_SECONDARY_SEGMENT_TBL_SRCH (1ULL << 61)
35#define CXL_PE_TAGS_ACTIVE (1ULL << 60)
36#define CXL_PE_USER_STATE (1ULL << 59)
37#define CXL_PE_TRANSLATION_ENABLED (1ULL << 58)
38#define CXL_PE_64_BIT (1ULL << 57)
39#define CXL_PE_PRIVILEGED_PROCESS (1ULL << 56)
40
41#define CXL_PROCESS_ELEMENT_VERSION 1
42struct cxl_process_element_hcall {
43 __be64 version;
44 __be64 flags;
45 u8 reserved0[12];
46 __be32 pslVirtualIsn;
47 u8 applicationVirtualIsnBitmap[256];
48 u8 reserved1[144];
49 struct cxl_process_element_common common;
50 u8 reserved4[12];
51} __packed;
52
53#define H_STATE_NORMAL 1
54#define H_STATE_DISABLE 2
55#define H_STATE_TEMP_UNAVAILABLE 3
56#define H_STATE_PERM_UNAVAILABLE 4
57
58/* NOTE: element must be a logical real address, and must be pinned */
59long cxl_h_attach_process(u64 unit_address, struct cxl_process_element_hcall *element,
60 u64 *process_token, u64 *mmio_addr, u64 *mmio_size);
61
62/**
63 * cxl_h_detach_process - Detach a process element from a coherent
64 * platform function.
65 */
66long cxl_h_detach_process(u64 unit_address, u64 process_token);
67
68/**
69 * cxl_h_reset_afu - Perform a reset to the coherent platform function.
70 */
71long cxl_h_reset_afu(u64 unit_address);
72
73/**
74 * cxl_h_suspend_process - Suspend a process from being executed
75 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
76 * process was attached.
77 */
78long cxl_h_suspend_process(u64 unit_address, u64 process_token);
79
80/**
81 * cxl_h_resume_process - Resume a process to be executed
82 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
83 * process was attached.
84 */
85long cxl_h_resume_process(u64 unit_address, u64 process_token);
86
87/**
88 * cxl_h_read_error_state - Reads the error state of the coherent
89 * platform function.
90 * R4 contains the error state
91 */
92long cxl_h_read_error_state(u64 unit_address, u64 *state);
93
94/**
95 * cxl_h_get_afu_err - collect the AFU error buffer
96 * Parameter1 = byte offset into error buffer to retrieve, valid values
97 * are between 0 and (ibm,error-buffer-size - 1)
98 * Parameter2 = 4K aligned real address of error buffer, to be filled in
99 * Parameter3 = length of error buffer, valid values are 4K or less
100 */
101long cxl_h_get_afu_err(u64 unit_address, u64 offset, u64 buf_address, u64 len);
102
103/**
104 * cxl_h_get_config - collect configuration record for the
105 * coherent platform function
106 * Parameter1 = # of configuration record to retrieve, valid values are
107 * between 0 and (ibm,#config-records - 1)
108 * Parameter2 = byte offset into configuration record to retrieve,
109 * valid values are between 0 and (ibm,config-record-size - 1)
110 * Parameter3 = 4K aligned real address of configuration record buffer,
111 * to be filled in
112 * Parameter4 = length of configuration buffer, valid values are 4K or less
113 */
114long cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset,
115 u64 buf_address, u64 len);
116
117/**
118 * cxl_h_terminate_process - Terminate the process before completion
119 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
120 * process was attached.
121 */
122long cxl_h_terminate_process(u64 unit_address, u64 process_token);
123
124/**
125 * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
126 * Parameter1 = # of VPD record to retrieve, valid values are between 0
127 * and (ibm,#config-records - 1).
128 * Parameter2 = 4K naturally aligned real buffer containing block
129 * list entries
130 * Parameter3 = number of block list entries in the block list, valid
131 * values are between 0 and 256
132 */
133long cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address,
134 u64 num, u64 *out);
135
136/**
137 * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt
138 */
139long cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg);
140
141/**
142 * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data
143 * based on an interrupt
144 * Parameter1 = value to write to the function-wide error interrupt register
145 */
146long cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value);
147
148/**
149 * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of
150 * an error log
151 */
152long cxl_h_get_error_log(u64 unit_address, u64 value);
153
154/**
155 * cxl_h_collect_int_info - Collect interrupt info about a coherent
156 * platform function after an interrupt occurred.
157 */
158long cxl_h_collect_int_info(u64 unit_address, u64 process_token,
159 struct cxl_irq_info *info);
160
161/**
162 * cxl_h_control_faults - Control the operation of a coherent platform
163 * function after a fault occurs.
164 *
165 * Parameters
166 * control-mask: value to control the faults
167 * looks like PSL_TFC_An shifted >> 32
168 * reset-mask: mask to control reset of function faults
169 * Set reset_mask = 1 to reset PSL errors
170 */
171long cxl_h_control_faults(u64 unit_address, u64 process_token,
172 u64 control_mask, u64 reset_mask);
173
174/**
175 * cxl_h_reset_adapter - Perform a reset to the coherent platform facility.
176 */
177long cxl_h_reset_adapter(u64 unit_address);
178
179/**
180 * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
181 * Parameter1 = 4K naturally aligned real buffer containing block
182 * list entries
183 * Parameter2 = number of block list entries in the block list, valid
184 * values are between 0 and 256
185 */
186long cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address,
187 u64 num, u64 *out);
188
189/**
190 * cxl_h_download_adapter_image - Download the base image to the coherent
191 * platform facility.
192 */
193long cxl_h_download_adapter_image(u64 unit_address,
194 u64 list_address, u64 num,
195 u64 *out);
196
197/**
198 * cxl_h_validate_adapter_image - Validate the base image in the coherent
199 * platform facility.
200 */
201long cxl_h_validate_adapter_image(u64 unit_address,
202 u64 list_address, u64 num,
203 u64 *out);
204#endif /* _HCALLS_H */
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright 2015 IBM Corp.
4 */
5
6#ifndef _HCALLS_H
7#define _HCALLS_H
8
9#include <linux/types.h>
10#include <asm/byteorder.h>
11#include <asm/hvcall.h>
12#include "cxl.h"
13
14#define SG_BUFFER_SIZE 4096
15#define SG_MAX_ENTRIES 256
16
17struct sg_list {
18 u64 phys_addr;
19 u64 len;
20};
21
22/*
23 * This is straight out of PAPR, but replacing some of the compound fields with
24 * a single field, where they were identical to the register layout.
25 *
26 * The 'flags' parameter regroups the various bit-fields
27 */
28#define CXL_PE_CSRP_VALID (1ULL << 63)
29#define CXL_PE_PROBLEM_STATE (1ULL << 62)
30#define CXL_PE_SECONDARY_SEGMENT_TBL_SRCH (1ULL << 61)
31#define CXL_PE_TAGS_ACTIVE (1ULL << 60)
32#define CXL_PE_USER_STATE (1ULL << 59)
33#define CXL_PE_TRANSLATION_ENABLED (1ULL << 58)
34#define CXL_PE_64_BIT (1ULL << 57)
35#define CXL_PE_PRIVILEGED_PROCESS (1ULL << 56)
36
37#define CXL_PROCESS_ELEMENT_VERSION 1
38struct cxl_process_element_hcall {
39 __be64 version;
40 __be64 flags;
41 u8 reserved0[12];
42 __be32 pslVirtualIsn;
43 u8 applicationVirtualIsnBitmap[256];
44 u8 reserved1[144];
45 struct cxl_process_element_common common;
46 u8 reserved4[12];
47} __packed;
48
49#define H_STATE_NORMAL 1
50#define H_STATE_DISABLE 2
51#define H_STATE_TEMP_UNAVAILABLE 3
52#define H_STATE_PERM_UNAVAILABLE 4
53
54/* NOTE: element must be a logical real address, and must be pinned */
55long cxl_h_attach_process(u64 unit_address, struct cxl_process_element_hcall *element,
56 u64 *process_token, u64 *mmio_addr, u64 *mmio_size);
57
58/**
59 * cxl_h_detach_process - Detach a process element from a coherent
60 * platform function.
61 */
62long cxl_h_detach_process(u64 unit_address, u64 process_token);
63
64/**
65 * cxl_h_reset_afu - Perform a reset to the coherent platform function.
66 */
67long cxl_h_reset_afu(u64 unit_address);
68
69/**
70 * cxl_h_suspend_process - Suspend a process from being executed
71 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
72 * process was attached.
73 */
74long cxl_h_suspend_process(u64 unit_address, u64 process_token);
75
76/**
77 * cxl_h_resume_process - Resume a process to be executed
78 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
79 * process was attached.
80 */
81long cxl_h_resume_process(u64 unit_address, u64 process_token);
82
83/**
84 * cxl_h_read_error_state - Reads the error state of the coherent
85 * platform function.
86 * R4 contains the error state
87 */
88long cxl_h_read_error_state(u64 unit_address, u64 *state);
89
90/**
91 * cxl_h_get_afu_err - collect the AFU error buffer
92 * Parameter1 = byte offset into error buffer to retrieve, valid values
93 * are between 0 and (ibm,error-buffer-size - 1)
94 * Parameter2 = 4K aligned real address of error buffer, to be filled in
95 * Parameter3 = length of error buffer, valid values are 4K or less
96 */
97long cxl_h_get_afu_err(u64 unit_address, u64 offset, u64 buf_address, u64 len);
98
99/**
100 * cxl_h_get_config - collect configuration record for the
101 * coherent platform function
102 * Parameter1 = # of configuration record to retrieve, valid values are
103 * between 0 and (ibm,#config-records - 1)
104 * Parameter2 = byte offset into configuration record to retrieve,
105 * valid values are between 0 and (ibm,config-record-size - 1)
106 * Parameter3 = 4K aligned real address of configuration record buffer,
107 * to be filled in
108 * Parameter4 = length of configuration buffer, valid values are 4K or less
109 */
110long cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset,
111 u64 buf_address, u64 len);
112
113/**
114 * cxl_h_terminate_process - Terminate the process before completion
115 * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
116 * process was attached.
117 */
118long cxl_h_terminate_process(u64 unit_address, u64 process_token);
119
120/**
121 * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
122 * Parameter1 = # of VPD record to retrieve, valid values are between 0
123 * and (ibm,#config-records - 1).
124 * Parameter2 = 4K naturally aligned real buffer containing block
125 * list entries
126 * Parameter3 = number of block list entries in the block list, valid
127 * values are between 0 and 256
128 */
129long cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address,
130 u64 num, u64 *out);
131
132/**
133 * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt
134 */
135long cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg);
136
137/**
138 * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data
139 * based on an interrupt
140 * Parameter1 = value to write to the function-wide error interrupt register
141 */
142long cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value);
143
144/**
145 * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of
146 * an error log
147 */
148long cxl_h_get_error_log(u64 unit_address, u64 value);
149
150/**
151 * cxl_h_collect_int_info - Collect interrupt info about a coherent
152 * platform function after an interrupt occurred.
153 */
154long cxl_h_collect_int_info(u64 unit_address, u64 process_token,
155 struct cxl_irq_info *info);
156
157/**
158 * cxl_h_control_faults - Control the operation of a coherent platform
159 * function after a fault occurs.
160 *
161 * Parameters
162 * control-mask: value to control the faults
163 * looks like PSL_TFC_An shifted >> 32
164 * reset-mask: mask to control reset of function faults
165 * Set reset_mask = 1 to reset PSL errors
166 */
167long cxl_h_control_faults(u64 unit_address, u64 process_token,
168 u64 control_mask, u64 reset_mask);
169
170/**
171 * cxl_h_reset_adapter - Perform a reset to the coherent platform facility.
172 */
173long cxl_h_reset_adapter(u64 unit_address);
174
175/**
176 * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
177 * Parameter1 = 4K naturally aligned real buffer containing block
178 * list entries
179 * Parameter2 = number of block list entries in the block list, valid
180 * values are between 0 and 256
181 */
182long cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address,
183 u64 num, u64 *out);
184
185/**
186 * cxl_h_download_adapter_image - Download the base image to the coherent
187 * platform facility.
188 */
189long cxl_h_download_adapter_image(u64 unit_address,
190 u64 list_address, u64 num,
191 u64 *out);
192
193/**
194 * cxl_h_validate_adapter_image - Validate the base image in the coherent
195 * platform facility.
196 */
197long cxl_h_validate_adapter_image(u64 unit_address,
198 u64 list_address, u64 num,
199 u64 *out);
200#endif /* _HCALLS_H */