1*963ed931SMartin Schwidefsky /* 2*963ed931SMartin Schwidefsky * linux/drivers/s390/crypto/zcrypt_error.h 3*963ed931SMartin Schwidefsky * 4*963ed931SMartin Schwidefsky * zcrypt 2.0.0 5*963ed931SMartin Schwidefsky * 6*963ed931SMartin Schwidefsky * Copyright (C) 2001, 2006 IBM Corporation 7*963ed931SMartin Schwidefsky * Author(s): Robert Burroughs 8*963ed931SMartin Schwidefsky * Eric Rossman (edrossma@us.ibm.com) 9*963ed931SMartin Schwidefsky * 10*963ed931SMartin Schwidefsky * Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com) 11*963ed931SMartin Schwidefsky * Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com> 12*963ed931SMartin Schwidefsky * 13*963ed931SMartin Schwidefsky * This program is free software; you can redistribute it and/or modify 14*963ed931SMartin Schwidefsky * it under the terms of the GNU General Public License as published by 15*963ed931SMartin Schwidefsky * the Free Software Foundation; either version 2, or (at your option) 16*963ed931SMartin Schwidefsky * any later version. 17*963ed931SMartin Schwidefsky * 18*963ed931SMartin Schwidefsky * This program is distributed in the hope that it will be useful, 19*963ed931SMartin Schwidefsky * but WITHOUT ANY WARRANTY; without even the implied warranty of 20*963ed931SMartin Schwidefsky * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*963ed931SMartin Schwidefsky * GNU General Public License for more details. 22*963ed931SMartin Schwidefsky * 23*963ed931SMartin Schwidefsky * You should have received a copy of the GNU General Public License 24*963ed931SMartin Schwidefsky * along with this program; if not, write to the Free Software 25*963ed931SMartin Schwidefsky * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26*963ed931SMartin Schwidefsky */ 27*963ed931SMartin Schwidefsky 28*963ed931SMartin Schwidefsky #ifndef _ZCRYPT_ERROR_H_ 29*963ed931SMartin Schwidefsky #define _ZCRYPT_ERROR_H_ 30*963ed931SMartin Schwidefsky 31*963ed931SMartin Schwidefsky #include "zcrypt_api.h" 32*963ed931SMartin Schwidefsky 33*963ed931SMartin Schwidefsky /** 34*963ed931SMartin Schwidefsky * Reply Messages 35*963ed931SMartin Schwidefsky * 36*963ed931SMartin Schwidefsky * Error reply messages are of two types: 37*963ed931SMartin Schwidefsky * 82: Error (see below) 38*963ed931SMartin Schwidefsky * 88: Error (see below) 39*963ed931SMartin Schwidefsky * Both type 82 and type 88 have the same structure in the header. 40*963ed931SMartin Schwidefsky * 41*963ed931SMartin Schwidefsky * Request reply messages are of three known types: 42*963ed931SMartin Schwidefsky * 80: Reply from a Type 50 Request (see CEX2A-RELATED STRUCTS) 43*963ed931SMartin Schwidefsky * 84: Reply from a Type 4 Request (see PCICA-RELATED STRUCTS) 44*963ed931SMartin Schwidefsky * 86: Reply from a Type 6 Request (see PCICC/PCIXCC/CEX2C-RELATED STRUCTS) 45*963ed931SMartin Schwidefsky * 46*963ed931SMartin Schwidefsky */ 47*963ed931SMartin Schwidefsky struct error_hdr { 48*963ed931SMartin Schwidefsky unsigned char reserved1; /* 0x00 */ 49*963ed931SMartin Schwidefsky unsigned char type; /* 0x82 or 0x88 */ 50*963ed931SMartin Schwidefsky unsigned char reserved2[2]; /* 0x0000 */ 51*963ed931SMartin Schwidefsky unsigned char reply_code; /* reply code */ 52*963ed931SMartin Schwidefsky unsigned char reserved3[3]; /* 0x000000 */ 53*963ed931SMartin Schwidefsky }; 54*963ed931SMartin Schwidefsky 55*963ed931SMartin Schwidefsky #define TYPE82_RSP_CODE 0x82 56*963ed931SMartin Schwidefsky #define TYPE88_RSP_CODE 0x88 57*963ed931SMartin Schwidefsky 58*963ed931SMartin Schwidefsky #define REP82_ERROR_MACHINE_FAILURE 0x10 59*963ed931SMartin Schwidefsky #define REP82_ERROR_PREEMPT_FAILURE 0x12 60*963ed931SMartin Schwidefsky #define REP82_ERROR_CHECKPT_FAILURE 0x14 61*963ed931SMartin Schwidefsky #define REP82_ERROR_MESSAGE_TYPE 0x20 62*963ed931SMartin Schwidefsky #define REP82_ERROR_INVALID_COMM_CD 0x21 /* Type 84 */ 63*963ed931SMartin Schwidefsky #define REP82_ERROR_INVALID_MSG_LEN 0x23 64*963ed931SMartin Schwidefsky #define REP82_ERROR_RESERVD_FIELD 0x24 /* was 0x50 */ 65*963ed931SMartin Schwidefsky #define REP82_ERROR_FORMAT_FIELD 0x29 66*963ed931SMartin Schwidefsky #define REP82_ERROR_INVALID_COMMAND 0x30 67*963ed931SMartin Schwidefsky #define REP82_ERROR_MALFORMED_MSG 0x40 68*963ed931SMartin Schwidefsky #define REP82_ERROR_RESERVED_FIELDO 0x50 /* old value */ 69*963ed931SMartin Schwidefsky #define REP82_ERROR_WORD_ALIGNMENT 0x60 70*963ed931SMartin Schwidefsky #define REP82_ERROR_MESSAGE_LENGTH 0x80 71*963ed931SMartin Schwidefsky #define REP82_ERROR_OPERAND_INVALID 0x82 72*963ed931SMartin Schwidefsky #define REP82_ERROR_OPERAND_SIZE 0x84 73*963ed931SMartin Schwidefsky #define REP82_ERROR_EVEN_MOD_IN_OPND 0x85 74*963ed931SMartin Schwidefsky #define REP82_ERROR_RESERVED_FIELD 0x88 75*963ed931SMartin Schwidefsky #define REP82_ERROR_TRANSPORT_FAIL 0x90 76*963ed931SMartin Schwidefsky #define REP82_ERROR_PACKET_TRUNCATED 0xA0 77*963ed931SMartin Schwidefsky #define REP82_ERROR_ZERO_BUFFER_LEN 0xB0 78*963ed931SMartin Schwidefsky 79*963ed931SMartin Schwidefsky #define REP88_ERROR_MODULE_FAILURE 0x10 80*963ed931SMartin Schwidefsky 81*963ed931SMartin Schwidefsky #define REP88_ERROR_MESSAGE_TYPE 0x20 82*963ed931SMartin Schwidefsky #define REP88_ERROR_MESSAGE_MALFORMD 0x22 83*963ed931SMartin Schwidefsky #define REP88_ERROR_MESSAGE_LENGTH 0x23 84*963ed931SMartin Schwidefsky #define REP88_ERROR_RESERVED_FIELD 0x24 85*963ed931SMartin Schwidefsky #define REP88_ERROR_KEY_TYPE 0x34 86*963ed931SMartin Schwidefsky #define REP88_ERROR_INVALID_KEY 0x82 /* CEX2A */ 87*963ed931SMartin Schwidefsky #define REP88_ERROR_OPERAND 0x84 /* CEX2A */ 88*963ed931SMartin Schwidefsky #define REP88_ERROR_OPERAND_EVEN_MOD 0x85 /* CEX2A */ 89*963ed931SMartin Schwidefsky 90*963ed931SMartin Schwidefsky static inline int convert_error(struct zcrypt_device *zdev, 91*963ed931SMartin Schwidefsky struct ap_message *reply) 92*963ed931SMartin Schwidefsky { 93*963ed931SMartin Schwidefsky struct error_hdr *ehdr = reply->message; 94*963ed931SMartin Schwidefsky 95*963ed931SMartin Schwidefsky PRINTK("Hardware error : Type %02x Message Header: %08x%08x\n", 96*963ed931SMartin Schwidefsky ehdr->type, *(unsigned int *) reply->message, 97*963ed931SMartin Schwidefsky *(unsigned int *) (reply->message + 4)); 98*963ed931SMartin Schwidefsky 99*963ed931SMartin Schwidefsky switch (ehdr->reply_code) { 100*963ed931SMartin Schwidefsky case REP82_ERROR_OPERAND_INVALID: 101*963ed931SMartin Schwidefsky case REP82_ERROR_OPERAND_SIZE: 102*963ed931SMartin Schwidefsky case REP82_ERROR_EVEN_MOD_IN_OPND: 103*963ed931SMartin Schwidefsky case REP88_ERROR_MESSAGE_MALFORMD: 104*963ed931SMartin Schwidefsky // REP88_ERROR_INVALID_KEY // '82' CEX2A 105*963ed931SMartin Schwidefsky // REP88_ERROR_OPERAND // '84' CEX2A 106*963ed931SMartin Schwidefsky // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A 107*963ed931SMartin Schwidefsky /* Invalid input data. */ 108*963ed931SMartin Schwidefsky return -EINVAL; 109*963ed931SMartin Schwidefsky case REP82_ERROR_MESSAGE_TYPE: 110*963ed931SMartin Schwidefsky // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A 111*963ed931SMartin Schwidefsky /** 112*963ed931SMartin Schwidefsky * To sent a message of the wrong type is a bug in the 113*963ed931SMartin Schwidefsky * device driver. Warn about it, disable the device 114*963ed931SMartin Schwidefsky * and then repeat the request. 115*963ed931SMartin Schwidefsky */ 116*963ed931SMartin Schwidefsky WARN_ON(1); 117*963ed931SMartin Schwidefsky zdev->online = 0; 118*963ed931SMartin Schwidefsky return -EAGAIN; 119*963ed931SMartin Schwidefsky case REP82_ERROR_TRANSPORT_FAIL: 120*963ed931SMartin Schwidefsky case REP82_ERROR_MACHINE_FAILURE: 121*963ed931SMartin Schwidefsky // REP88_ERROR_MODULE_FAILURE // '10' CEX2A 122*963ed931SMartin Schwidefsky /* If a card fails disable it and repeat the request. */ 123*963ed931SMartin Schwidefsky zdev->online = 0; 124*963ed931SMartin Schwidefsky return -EAGAIN; 125*963ed931SMartin Schwidefsky default: 126*963ed931SMartin Schwidefsky PRINTKW("unknown type %02x reply code = %d\n", 127*963ed931SMartin Schwidefsky ehdr->type, ehdr->reply_code); 128*963ed931SMartin Schwidefsky zdev->online = 0; 129*963ed931SMartin Schwidefsky return -EAGAIN; /* repeat the request on a different device. */ 130*963ed931SMartin Schwidefsky } 131*963ed931SMartin Schwidefsky } 132*963ed931SMartin Schwidefsky 133*963ed931SMartin Schwidefsky #endif /* _ZCRYPT_ERROR_H_ */ 134