1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * channel program interfaces 4 * 5 * Copyright IBM Corp. 2017 6 * 7 * Author(s): Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> 8 * Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> 9 */ 10 11 #ifndef _VFIO_CCW_CP_H_ 12 #define _VFIO_CCW_CP_H_ 13 14 #include <asm/cio.h> 15 #include <asm/scsw.h> 16 17 #include "orb.h" 18 #include "vfio_ccw_trace.h" 19 20 /* 21 * Max length for ccw chain. 22 * XXX: Limit to 256, need to check more? 23 */ 24 #define CCWCHAIN_LEN_MAX 256 25 26 /* 27 * Maximum number of chains 28 */ 29 #define CCWCHAIN_COUNT_MAX 16 30 31 /** 32 * struct channel_program - manage information for channel program 33 * @ccwchain_list: list head of ccwchains 34 * @orb: orb for the currently processed ssch request 35 * @initialized: whether this instance is actually initialized 36 * @guest_cp: copy of guest channel program 37 * @ccwchain_count: number of channel program segments (linked by TIC) 38 * @guest_iova: first data address of a guest channel program 39 * 40 * @ccwchain_list is the head of a ccwchain list, that contents the 41 * translated result of the guest channel program that pointed out by 42 * the iova parameter when calling cp_init. 43 */ 44 struct channel_program { 45 struct list_head ccwchain_list; 46 union orb orb; 47 bool initialized; 48 struct ccw1 *guest_cp; 49 unsigned int ccwchain_count; 50 u64 guest_iova; 51 }; 52 53 int cp_init(struct channel_program *cp, union orb *orb); 54 void cp_free(struct channel_program *cp); 55 int cp_prefetch(struct channel_program *cp); 56 union orb *cp_get_orb(struct channel_program *cp, struct subchannel *sch); 57 void cp_update_scsw(struct channel_program *cp, union scsw *scsw); 58 bool cp_iova_pinned(struct channel_program *cp, u64 iova, u64 length); 59 60 #endif 61