162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2015 IBM Corp. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef _HCALLS_H 762306a36Sopenharmony_ci#define _HCALLS_H 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/types.h> 1062306a36Sopenharmony_ci#include <asm/byteorder.h> 1162306a36Sopenharmony_ci#include <asm/hvcall.h> 1262306a36Sopenharmony_ci#include "cxl.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define SG_BUFFER_SIZE 4096 1562306a36Sopenharmony_ci#define SG_MAX_ENTRIES 256 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct sg_list { 1862306a36Sopenharmony_ci u64 phys_addr; 1962306a36Sopenharmony_ci u64 len; 2062306a36Sopenharmony_ci}; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* 2362306a36Sopenharmony_ci * This is straight out of PAPR, but replacing some of the compound fields with 2462306a36Sopenharmony_ci * a single field, where they were identical to the register layout. 2562306a36Sopenharmony_ci * 2662306a36Sopenharmony_ci * The 'flags' parameter regroups the various bit-fields 2762306a36Sopenharmony_ci */ 2862306a36Sopenharmony_ci#define CXL_PE_CSRP_VALID (1ULL << 63) 2962306a36Sopenharmony_ci#define CXL_PE_PROBLEM_STATE (1ULL << 62) 3062306a36Sopenharmony_ci#define CXL_PE_SECONDARY_SEGMENT_TBL_SRCH (1ULL << 61) 3162306a36Sopenharmony_ci#define CXL_PE_TAGS_ACTIVE (1ULL << 60) 3262306a36Sopenharmony_ci#define CXL_PE_USER_STATE (1ULL << 59) 3362306a36Sopenharmony_ci#define CXL_PE_TRANSLATION_ENABLED (1ULL << 58) 3462306a36Sopenharmony_ci#define CXL_PE_64_BIT (1ULL << 57) 3562306a36Sopenharmony_ci#define CXL_PE_PRIVILEGED_PROCESS (1ULL << 56) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define CXL_PROCESS_ELEMENT_VERSION 1 3862306a36Sopenharmony_cistruct cxl_process_element_hcall { 3962306a36Sopenharmony_ci __be64 version; 4062306a36Sopenharmony_ci __be64 flags; 4162306a36Sopenharmony_ci u8 reserved0[12]; 4262306a36Sopenharmony_ci __be32 pslVirtualIsn; 4362306a36Sopenharmony_ci u8 applicationVirtualIsnBitmap[256]; 4462306a36Sopenharmony_ci u8 reserved1[144]; 4562306a36Sopenharmony_ci struct cxl_process_element_common common; 4662306a36Sopenharmony_ci u8 reserved4[12]; 4762306a36Sopenharmony_ci} __packed; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define H_STATE_NORMAL 1 5062306a36Sopenharmony_ci#define H_STATE_DISABLE 2 5162306a36Sopenharmony_ci#define H_STATE_TEMP_UNAVAILABLE 3 5262306a36Sopenharmony_ci#define H_STATE_PERM_UNAVAILABLE 4 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* NOTE: element must be a logical real address, and must be pinned */ 5562306a36Sopenharmony_cilong cxl_h_attach_process(u64 unit_address, struct cxl_process_element_hcall *element, 5662306a36Sopenharmony_ci u64 *process_token, u64 *mmio_addr, u64 *mmio_size); 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci/** 5962306a36Sopenharmony_ci * cxl_h_detach_process - Detach a process element from a coherent 6062306a36Sopenharmony_ci * platform function. 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cilong cxl_h_detach_process(u64 unit_address, u64 process_token); 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/** 6562306a36Sopenharmony_ci * cxl_h_reset_afu - Perform a reset to the coherent platform function. 6662306a36Sopenharmony_ci */ 6762306a36Sopenharmony_cilong cxl_h_reset_afu(u64 unit_address); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/** 7062306a36Sopenharmony_ci * cxl_h_suspend_process - Suspend a process from being executed 7162306a36Sopenharmony_ci * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when 7262306a36Sopenharmony_ci * process was attached. 7362306a36Sopenharmony_ci */ 7462306a36Sopenharmony_cilong cxl_h_suspend_process(u64 unit_address, u64 process_token); 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/** 7762306a36Sopenharmony_ci * cxl_h_resume_process - Resume a process to be executed 7862306a36Sopenharmony_ci * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when 7962306a36Sopenharmony_ci * process was attached. 8062306a36Sopenharmony_ci */ 8162306a36Sopenharmony_cilong cxl_h_resume_process(u64 unit_address, u64 process_token); 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/** 8462306a36Sopenharmony_ci * cxl_h_read_error_state - Reads the error state of the coherent 8562306a36Sopenharmony_ci * platform function. 8662306a36Sopenharmony_ci * R4 contains the error state 8762306a36Sopenharmony_ci */ 8862306a36Sopenharmony_cilong cxl_h_read_error_state(u64 unit_address, u64 *state); 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci/** 9162306a36Sopenharmony_ci * cxl_h_get_afu_err - collect the AFU error buffer 9262306a36Sopenharmony_ci * Parameter1 = byte offset into error buffer to retrieve, valid values 9362306a36Sopenharmony_ci * are between 0 and (ibm,error-buffer-size - 1) 9462306a36Sopenharmony_ci * Parameter2 = 4K aligned real address of error buffer, to be filled in 9562306a36Sopenharmony_ci * Parameter3 = length of error buffer, valid values are 4K or less 9662306a36Sopenharmony_ci */ 9762306a36Sopenharmony_cilong cxl_h_get_afu_err(u64 unit_address, u64 offset, u64 buf_address, u64 len); 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci/** 10062306a36Sopenharmony_ci * cxl_h_get_config - collect configuration record for the 10162306a36Sopenharmony_ci * coherent platform function 10262306a36Sopenharmony_ci * Parameter1 = # of configuration record to retrieve, valid values are 10362306a36Sopenharmony_ci * between 0 and (ibm,#config-records - 1) 10462306a36Sopenharmony_ci * Parameter2 = byte offset into configuration record to retrieve, 10562306a36Sopenharmony_ci * valid values are between 0 and (ibm,config-record-size - 1) 10662306a36Sopenharmony_ci * Parameter3 = 4K aligned real address of configuration record buffer, 10762306a36Sopenharmony_ci * to be filled in 10862306a36Sopenharmony_ci * Parameter4 = length of configuration buffer, valid values are 4K or less 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_cilong cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset, 11162306a36Sopenharmony_ci u64 buf_address, u64 len); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci/** 11462306a36Sopenharmony_ci * cxl_h_terminate_process - Terminate the process before completion 11562306a36Sopenharmony_ci * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when 11662306a36Sopenharmony_ci * process was attached. 11762306a36Sopenharmony_ci */ 11862306a36Sopenharmony_cilong cxl_h_terminate_process(u64 unit_address, u64 process_token); 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/** 12162306a36Sopenharmony_ci * cxl_h_collect_vpd - Collect VPD for the coherent platform function. 12262306a36Sopenharmony_ci * Parameter1 = # of VPD record to retrieve, valid values are between 0 12362306a36Sopenharmony_ci * and (ibm,#config-records - 1). 12462306a36Sopenharmony_ci * Parameter2 = 4K naturally aligned real buffer containing block 12562306a36Sopenharmony_ci * list entries 12662306a36Sopenharmony_ci * Parameter3 = number of block list entries in the block list, valid 12762306a36Sopenharmony_ci * values are between 0 and 256 12862306a36Sopenharmony_ci */ 12962306a36Sopenharmony_cilong cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address, 13062306a36Sopenharmony_ci u64 num, u64 *out); 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci/** 13362306a36Sopenharmony_ci * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt 13462306a36Sopenharmony_ci */ 13562306a36Sopenharmony_cilong cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg); 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci/** 13862306a36Sopenharmony_ci * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data 13962306a36Sopenharmony_ci * based on an interrupt 14062306a36Sopenharmony_ci * Parameter1 = value to write to the function-wide error interrupt register 14162306a36Sopenharmony_ci */ 14262306a36Sopenharmony_cilong cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value); 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/** 14562306a36Sopenharmony_ci * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of 14662306a36Sopenharmony_ci * an error log 14762306a36Sopenharmony_ci */ 14862306a36Sopenharmony_cilong cxl_h_get_error_log(u64 unit_address, u64 value); 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci/** 15162306a36Sopenharmony_ci * cxl_h_collect_int_info - Collect interrupt info about a coherent 15262306a36Sopenharmony_ci * platform function after an interrupt occurred. 15362306a36Sopenharmony_ci */ 15462306a36Sopenharmony_cilong cxl_h_collect_int_info(u64 unit_address, u64 process_token, 15562306a36Sopenharmony_ci struct cxl_irq_info *info); 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci/** 15862306a36Sopenharmony_ci * cxl_h_control_faults - Control the operation of a coherent platform 15962306a36Sopenharmony_ci * function after a fault occurs. 16062306a36Sopenharmony_ci * 16162306a36Sopenharmony_ci * Parameters 16262306a36Sopenharmony_ci * control-mask: value to control the faults 16362306a36Sopenharmony_ci * looks like PSL_TFC_An shifted >> 32 16462306a36Sopenharmony_ci * reset-mask: mask to control reset of function faults 16562306a36Sopenharmony_ci * Set reset_mask = 1 to reset PSL errors 16662306a36Sopenharmony_ci */ 16762306a36Sopenharmony_cilong cxl_h_control_faults(u64 unit_address, u64 process_token, 16862306a36Sopenharmony_ci u64 control_mask, u64 reset_mask); 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/** 17162306a36Sopenharmony_ci * cxl_h_reset_adapter - Perform a reset to the coherent platform facility. 17262306a36Sopenharmony_ci */ 17362306a36Sopenharmony_cilong cxl_h_reset_adapter(u64 unit_address); 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/** 17662306a36Sopenharmony_ci * cxl_h_collect_vpd - Collect VPD for the coherent platform function. 17762306a36Sopenharmony_ci * Parameter1 = 4K naturally aligned real buffer containing block 17862306a36Sopenharmony_ci * list entries 17962306a36Sopenharmony_ci * Parameter2 = number of block list entries in the block list, valid 18062306a36Sopenharmony_ci * values are between 0 and 256 18162306a36Sopenharmony_ci */ 18262306a36Sopenharmony_cilong cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address, 18362306a36Sopenharmony_ci u64 num, u64 *out); 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci/** 18662306a36Sopenharmony_ci * cxl_h_download_adapter_image - Download the base image to the coherent 18762306a36Sopenharmony_ci * platform facility. 18862306a36Sopenharmony_ci */ 18962306a36Sopenharmony_cilong cxl_h_download_adapter_image(u64 unit_address, 19062306a36Sopenharmony_ci u64 list_address, u64 num, 19162306a36Sopenharmony_ci u64 *out); 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci/** 19462306a36Sopenharmony_ci * cxl_h_validate_adapter_image - Validate the base image in the coherent 19562306a36Sopenharmony_ci * platform facility. 19662306a36Sopenharmony_ci */ 19762306a36Sopenharmony_cilong cxl_h_validate_adapter_image(u64 unit_address, 19862306a36Sopenharmony_ci u64 list_address, u64 num, 19962306a36Sopenharmony_ci u64 *out); 20062306a36Sopenharmony_ci#endif /* _HCALLS_H */ 201