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