1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright IBM Corp. 2001, 2012 4 * Author(s): Robert Burroughs 5 * Eric Rossman (edrossma@us.ibm.com) 6 * 7 * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com) 8 * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com> 9 * MSGTYPE restruct: Holger Dengler <hd@linux.vnet.ibm.com> 10 */ 11 12 #ifndef _ZCRYPT_MSGTYPE6_H_ 13 #define _ZCRYPT_MSGTYPE6_H_ 14 15 #include <asm/zcrypt.h> 16 17 #define MSGTYPE06_NAME "zcrypt_msgtype6" 18 #define MSGTYPE06_VARIANT_DEFAULT 0 19 #define MSGTYPE06_VARIANT_NORNG 1 20 #define MSGTYPE06_VARIANT_EP11 2 21 22 /** 23 * The type 6 message family is associated with CEXxC/CEXxP cards. 24 * 25 * It contains a message header followed by a CPRB, both of which 26 * are described below. 27 * 28 * Note that all reserved fields must be zeroes. 29 */ 30 struct type6_hdr { 31 unsigned char reserved1; /* 0x00 */ 32 unsigned char type; /* 0x06 */ 33 unsigned char reserved2[2]; /* 0x0000 */ 34 unsigned char right[4]; /* 0x00000000 */ 35 unsigned char reserved3[2]; /* 0x0000 */ 36 unsigned char reserved4[2]; /* 0x0000 */ 37 unsigned int apfs; /* 0x00000000 */ 38 unsigned int offset1; /* 0x00000058 (offset to CPRB) */ 39 unsigned int offset2; /* 0x00000000 */ 40 unsigned int offset3; /* 0x00000000 */ 41 unsigned int offset4; /* 0x00000000 */ 42 unsigned char agent_id[16]; /* 0x4341000000000000 */ 43 /* 0x0000000000000000 */ 44 unsigned char rqid[2]; /* rqid. internal to 603 */ 45 unsigned char reserved5[2]; /* 0x0000 */ 46 unsigned char function_code[2]; /* for PKD, 0x5044 (ascii 'PD') */ 47 unsigned char reserved6[2]; /* 0x0000 */ 48 unsigned int tocardlen1; /* (request CPRB len + 3) & -4 */ 49 unsigned int tocardlen2; /* db len 0x00000000 for PKD */ 50 unsigned int tocardlen3; /* 0x00000000 */ 51 unsigned int tocardlen4; /* 0x00000000 */ 52 unsigned int fromcardlen1; /* response buffer length */ 53 unsigned int fromcardlen2; /* db len 0x00000000 for PKD */ 54 unsigned int fromcardlen3; /* 0x00000000 */ 55 unsigned int fromcardlen4; /* 0x00000000 */ 56 } __packed; 57 58 /** 59 * The type 86 message family is associated with CEXxC/CEXxP cards. 60 * 61 * It contains a message header followed by a CPRB. The CPRB is 62 * the same as the request CPRB, which is described above. 63 * 64 * If format is 1, an error condition exists and no data beyond 65 * the 8-byte message header is of interest. 66 * 67 * The non-error message is shown below. 68 * 69 * Note that all reserved fields must be zeroes. 70 */ 71 struct type86_hdr { 72 unsigned char reserved1; /* 0x00 */ 73 unsigned char type; /* 0x86 */ 74 unsigned char format; /* 0x01 (error) or 0x02 (ok) */ 75 unsigned char reserved2; /* 0x00 */ 76 unsigned char reply_code; /* reply code (see above) */ 77 unsigned char reserved3[3]; /* 0x000000 */ 78 } __packed; 79 80 #define TYPE86_RSP_CODE 0x86 81 #define TYPE87_RSP_CODE 0x87 82 #define TYPE86_FMT2 0x02 83 84 struct type86_fmt2_ext { 85 unsigned char reserved[4]; /* 0x00000000 */ 86 unsigned int apfs; /* final status */ 87 unsigned int count1; /* length of CPRB + parameters */ 88 unsigned int offset1; /* offset to CPRB */ 89 unsigned int count2; /* 0x00000000 */ 90 unsigned int offset2; /* db offset 0x00000000 for PKD */ 91 unsigned int count3; /* 0x00000000 */ 92 unsigned int offset3; /* 0x00000000 */ 93 unsigned int count4; /* 0x00000000 */ 94 unsigned int offset4; /* 0x00000000 */ 95 } __packed; 96 97 int prep_cca_ap_msg(bool userspace, struct ica_xcRB *xcrb, 98 struct ap_message *ap_msg, 99 unsigned int *fc, unsigned int *dom); 100 int prep_ep11_ap_msg(bool userspace, struct ep11_urb *xcrb, 101 struct ap_message *ap_msg, 102 unsigned int *fc, unsigned int *dom); 103 int prep_rng_ap_msg(struct ap_message *ap_msg, 104 int *fc, unsigned int *dom); 105 106 #define LOW 10 107 #define MEDIUM 100 108 #define HIGH 500 109 110 int speed_idx_cca(int); 111 int speed_idx_ep11(int); 112 113 void zcrypt_msgtype6_init(void); 114 void zcrypt_msgtype6_exit(void); 115 116 #endif /* _ZCRYPT_MSGTYPE6_H_ */ 117