Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Copyright 2015 IBM Corp.
0004  */
0005 
0006 #ifndef _HCALLS_H
0007 #define _HCALLS_H
0008 
0009 #include <linux/types.h>
0010 #include <asm/byteorder.h>
0011 #include <asm/hvcall.h>
0012 #include "cxl.h"
0013 
0014 #define SG_BUFFER_SIZE 4096
0015 #define SG_MAX_ENTRIES 256
0016 
0017 struct sg_list {
0018     u64 phys_addr;
0019     u64 len;
0020 };
0021 
0022 /*
0023  * This is straight out of PAPR, but replacing some of the compound fields with
0024  * a single field, where they were identical to the register layout.
0025  *
0026  * The 'flags' parameter regroups the various bit-fields
0027  */
0028 #define CXL_PE_CSRP_VALID           (1ULL << 63)
0029 #define CXL_PE_PROBLEM_STATE            (1ULL << 62)
0030 #define CXL_PE_SECONDARY_SEGMENT_TBL_SRCH   (1ULL << 61)
0031 #define CXL_PE_TAGS_ACTIVE          (1ULL << 60)
0032 #define CXL_PE_USER_STATE           (1ULL << 59)
0033 #define CXL_PE_TRANSLATION_ENABLED      (1ULL << 58)
0034 #define CXL_PE_64_BIT               (1ULL << 57)
0035 #define CXL_PE_PRIVILEGED_PROCESS       (1ULL << 56)
0036 
0037 #define CXL_PROCESS_ELEMENT_VERSION 1
0038 struct cxl_process_element_hcall {
0039     __be64 version;
0040     __be64 flags;
0041     u8     reserved0[12];
0042     __be32 pslVirtualIsn;
0043     u8     applicationVirtualIsnBitmap[256];
0044     u8     reserved1[144];
0045     struct cxl_process_element_common common;
0046     u8     reserved4[12];
0047 } __packed;
0048 
0049 #define H_STATE_NORMAL              1
0050 #define H_STATE_DISABLE             2
0051 #define H_STATE_TEMP_UNAVAILABLE    3
0052 #define H_STATE_PERM_UNAVAILABLE    4
0053 
0054 /* NOTE: element must be a logical real address, and must be pinned */
0055 long cxl_h_attach_process(u64 unit_address, struct cxl_process_element_hcall *element,
0056             u64 *process_token, u64 *mmio_addr, u64 *mmio_size);
0057 
0058 /**
0059  * cxl_h_detach_process - Detach a process element from a coherent
0060  *                        platform function.
0061  */
0062 long cxl_h_detach_process(u64 unit_address, u64 process_token);
0063 
0064 /**
0065  * cxl_h_reset_afu - Perform a reset to the coherent platform function.
0066  */
0067 long cxl_h_reset_afu(u64 unit_address);
0068 
0069 /**
0070  * cxl_h_suspend_process - Suspend a process from being executed
0071  * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
0072  *              process was attached.
0073  */
0074 long cxl_h_suspend_process(u64 unit_address, u64 process_token);
0075 
0076 /**
0077  * cxl_h_resume_process - Resume a process to be executed
0078  * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
0079  *              process was attached.
0080  */
0081 long cxl_h_resume_process(u64 unit_address, u64 process_token);
0082 
0083 /**
0084  * cxl_h_read_error_state - Reads the error state of the coherent
0085  *                          platform function.
0086  * R4 contains the error state
0087  */
0088 long cxl_h_read_error_state(u64 unit_address, u64 *state);
0089 
0090 /**
0091  * cxl_h_get_afu_err - collect the AFU error buffer
0092  * Parameter1 = byte offset into error buffer to retrieve, valid values
0093  *              are between 0 and (ibm,error-buffer-size - 1)
0094  * Parameter2 = 4K aligned real address of error buffer, to be filled in
0095  * Parameter3 = length of error buffer, valid values are 4K or less
0096  */
0097 long cxl_h_get_afu_err(u64 unit_address, u64 offset, u64 buf_address, u64 len);
0098 
0099 /**
0100  * cxl_h_get_config - collect configuration record for the
0101  *                    coherent platform function
0102  * Parameter1 = # of configuration record to retrieve, valid values are
0103  *              between 0 and (ibm,#config-records - 1)
0104  * Parameter2 = byte offset into configuration record to retrieve,
0105  *              valid values are between 0 and (ibm,config-record-size - 1)
0106  * Parameter3 = 4K aligned real address of configuration record buffer,
0107  *              to be filled in
0108  * Parameter4 = length of configuration buffer, valid values are 4K or less
0109  */
0110 long cxl_h_get_config(u64 unit_address, u64 cr_num, u64 offset,
0111         u64 buf_address, u64 len);
0112 
0113 /**
0114  * cxl_h_terminate_process - Terminate the process before completion
0115  * Parameter1 = process-token as returned from H_ATTACH_CA_PROCESS when
0116  *              process was attached.
0117  */
0118 long cxl_h_terminate_process(u64 unit_address, u64 process_token);
0119 
0120 /**
0121  * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
0122  * Parameter1 = # of VPD record to retrieve, valid values are between 0
0123  *              and (ibm,#config-records - 1).
0124  * Parameter2 = 4K naturally aligned real buffer containing block
0125  *              list entries
0126  * Parameter3 = number of block list entries in the block list, valid
0127  *              values are between 0 and 256
0128  */
0129 long cxl_h_collect_vpd(u64 unit_address, u64 record, u64 list_address,
0130                u64 num, u64 *out);
0131 
0132 /**
0133  * cxl_h_get_fn_error_interrupt - Read the function-wide error data based on an interrupt
0134  */
0135 long cxl_h_get_fn_error_interrupt(u64 unit_address, u64 *reg);
0136 
0137 /**
0138  * cxl_h_ack_fn_error_interrupt - Acknowledge function-wide error data
0139  *                                based on an interrupt
0140  * Parameter1 = value to write to the function-wide error interrupt register
0141  */
0142 long cxl_h_ack_fn_error_interrupt(u64 unit_address, u64 value);
0143 
0144 /**
0145  * cxl_h_get_error_log - Retrieve the Platform Log ID (PLID) of
0146  *                       an error log
0147  */
0148 long cxl_h_get_error_log(u64 unit_address, u64 value);
0149 
0150 /**
0151  * cxl_h_collect_int_info - Collect interrupt info about a coherent
0152  *                          platform function after an interrupt occurred.
0153  */
0154 long cxl_h_collect_int_info(u64 unit_address, u64 process_token,
0155             struct cxl_irq_info *info);
0156 
0157 /**
0158  * cxl_h_control_faults - Control the operation of a coherent platform
0159  *                        function after a fault occurs.
0160  *
0161  * Parameters
0162  *    control-mask: value to control the faults
0163  *                  looks like PSL_TFC_An shifted >> 32
0164  *    reset-mask: mask to control reset of function faults
0165  *                Set reset_mask = 1 to reset PSL errors
0166  */
0167 long cxl_h_control_faults(u64 unit_address, u64 process_token,
0168             u64 control_mask, u64 reset_mask);
0169 
0170 /**
0171  * cxl_h_reset_adapter - Perform a reset to the coherent platform facility.
0172  */
0173 long cxl_h_reset_adapter(u64 unit_address);
0174 
0175 /**
0176  * cxl_h_collect_vpd - Collect VPD for the coherent platform function.
0177  * Parameter1 = 4K naturally aligned real buffer containing block
0178  *              list entries
0179  * Parameter2 = number of block list entries in the block list, valid
0180  *              values are between 0 and 256
0181  */
0182 long cxl_h_collect_vpd_adapter(u64 unit_address, u64 list_address,
0183                    u64 num, u64 *out);
0184 
0185 /**
0186  * cxl_h_download_adapter_image - Download the base image to the coherent
0187  *                                platform facility.
0188  */
0189 long cxl_h_download_adapter_image(u64 unit_address,
0190                   u64 list_address, u64 num,
0191                   u64 *out);
0192 
0193 /**
0194  * cxl_h_validate_adapter_image - Validate the base image in the coherent
0195  *                                platform facility.
0196  */
0197 long cxl_h_validate_adapter_image(u64 unit_address,
0198                   u64 list_address, u64 num,
0199                   u64 *out);
0200 #endif /* _HCALLS_H */