Commit 963ed931 authored by Martin Schwidefsky's avatar Martin Schwidefsky

[S390] zcrypt CEX2A, CEX2C, PCICA accelerator card ap bus drivers.

Signed-off-by: default avatarRalph Wuerthner <rwuerthn@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 2dbc2418
This diff is collapsed.
/*
* linux/drivers/s390/crypto/zcrypt_cex2a.h
*
* zcrypt 2.0.0
*
* Copyright (C) 2001, 2006 IBM Corporation
* Author(s): Robert Burroughs
* Eric Rossman (edrossma@us.ibm.com)
*
* Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
* Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ZCRYPT_CEX2A_H_
#define _ZCRYPT_CEX2A_H_
/**
* The type 50 message family is associated with a CEX2A card.
*
* The four members of the family are described below.
*
* Note that all unsigned char arrays are right-justified and left-padded
* with zeroes.
*
* Note that all reserved fields must be zeroes.
*/
struct type50_hdr {
unsigned char reserved1;
unsigned char msg_type_code; /* 0x50 */
unsigned short msg_len;
unsigned char reserved2;
unsigned char ignored;
unsigned short reserved3;
} __attribute__((packed));
#define TYPE50_TYPE_CODE 0x50
#define TYPE50_MEB1_FMT 0x0001
#define TYPE50_MEB2_FMT 0x0002
#define TYPE50_CRB1_FMT 0x0011
#define TYPE50_CRB2_FMT 0x0012
/* Mod-Exp, with a small modulus */
struct type50_meb1_msg {
struct type50_hdr header;
unsigned short keyblock_type; /* 0x0001 */
unsigned char reserved[6];
unsigned char exponent[128];
unsigned char modulus[128];
unsigned char message[128];
} __attribute__((packed));
/* Mod-Exp, with a large modulus */
struct type50_meb2_msg {
struct type50_hdr header;
unsigned short keyblock_type; /* 0x0002 */
unsigned char reserved[6];
unsigned char exponent[256];
unsigned char modulus[256];
unsigned char message[256];
} __attribute__((packed));
/* CRT, with a small modulus */
struct type50_crb1_msg {
struct type50_hdr header;
unsigned short keyblock_type; /* 0x0011 */
unsigned char reserved[6];
unsigned char p[64];
unsigned char q[64];
unsigned char dp[64];
unsigned char dq[64];
unsigned char u[64];
unsigned char message[128];
} __attribute__((packed));
/* CRT, with a large modulus */
struct type50_crb2_msg {
struct type50_hdr header;
unsigned short keyblock_type; /* 0x0012 */
unsigned char reserved[6];
unsigned char p[128];
unsigned char q[128];
unsigned char dp[128];
unsigned char dq[128];
unsigned char u[128];
unsigned char message[256];
} __attribute__((packed));
/**
* The type 80 response family is associated with a CEX2A card.
*
* Note that all unsigned char arrays are right-justified and left-padded
* with zeroes.
*
* Note that all reserved fields must be zeroes.
*/
#define TYPE80_RSP_CODE 0x80
struct type80_hdr {
unsigned char reserved1;
unsigned char type; /* 0x80 */
unsigned short len;
unsigned char code; /* 0x00 */
unsigned char reserved2[3];
unsigned char reserved3[8];
} __attribute__((packed));
int zcrypt_cex2a_init(void);
void zcrypt_cex2a_exit(void);
#endif /* _ZCRYPT_CEX2A_H_ */
/*
* linux/drivers/s390/crypto/zcrypt_error.h
*
* zcrypt 2.0.0
*
* Copyright (C) 2001, 2006 IBM Corporation
* Author(s): Robert Burroughs
* Eric Rossman (edrossma@us.ibm.com)
*
* Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
* Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ZCRYPT_ERROR_H_
#define _ZCRYPT_ERROR_H_
#include "zcrypt_api.h"
/**
* Reply Messages
*
* Error reply messages are of two types:
* 82: Error (see below)
* 88: Error (see below)
* Both type 82 and type 88 have the same structure in the header.
*
* Request reply messages are of three known types:
* 80: Reply from a Type 50 Request (see CEX2A-RELATED STRUCTS)
* 84: Reply from a Type 4 Request (see PCICA-RELATED STRUCTS)
* 86: Reply from a Type 6 Request (see PCICC/PCIXCC/CEX2C-RELATED STRUCTS)
*
*/
struct error_hdr {
unsigned char reserved1; /* 0x00 */
unsigned char type; /* 0x82 or 0x88 */
unsigned char reserved2[2]; /* 0x0000 */
unsigned char reply_code; /* reply code */
unsigned char reserved3[3]; /* 0x000000 */
};
#define TYPE82_RSP_CODE 0x82
#define TYPE88_RSP_CODE 0x88
#define REP82_ERROR_MACHINE_FAILURE 0x10
#define REP82_ERROR_PREEMPT_FAILURE 0x12
#define REP82_ERROR_CHECKPT_FAILURE 0x14
#define REP82_ERROR_MESSAGE_TYPE 0x20
#define REP82_ERROR_INVALID_COMM_CD 0x21 /* Type 84 */
#define REP82_ERROR_INVALID_MSG_LEN 0x23
#define REP82_ERROR_RESERVD_FIELD 0x24 /* was 0x50 */
#define REP82_ERROR_FORMAT_FIELD 0x29
#define REP82_ERROR_INVALID_COMMAND 0x30
#define REP82_ERROR_MALFORMED_MSG 0x40
#define REP82_ERROR_RESERVED_FIELDO 0x50 /* old value */
#define REP82_ERROR_WORD_ALIGNMENT 0x60
#define REP82_ERROR_MESSAGE_LENGTH 0x80
#define REP82_ERROR_OPERAND_INVALID 0x82
#define REP82_ERROR_OPERAND_SIZE 0x84
#define REP82_ERROR_EVEN_MOD_IN_OPND 0x85
#define REP82_ERROR_RESERVED_FIELD 0x88
#define REP82_ERROR_TRANSPORT_FAIL 0x90
#define REP82_ERROR_PACKET_TRUNCATED 0xA0
#define REP82_ERROR_ZERO_BUFFER_LEN 0xB0
#define REP88_ERROR_MODULE_FAILURE 0x10
#define REP88_ERROR_MESSAGE_TYPE 0x20
#define REP88_ERROR_MESSAGE_MALFORMD 0x22
#define REP88_ERROR_MESSAGE_LENGTH 0x23
#define REP88_ERROR_RESERVED_FIELD 0x24
#define REP88_ERROR_KEY_TYPE 0x34
#define REP88_ERROR_INVALID_KEY 0x82 /* CEX2A */
#define REP88_ERROR_OPERAND 0x84 /* CEX2A */
#define REP88_ERROR_OPERAND_EVEN_MOD 0x85 /* CEX2A */
static inline int convert_error(struct zcrypt_device *zdev,
struct ap_message *reply)
{
struct error_hdr *ehdr = reply->message;
PRINTK("Hardware error : Type %02x Message Header: %08x%08x\n",
ehdr->type, *(unsigned int *) reply->message,
*(unsigned int *) (reply->message + 4));
switch (ehdr->reply_code) {
case REP82_ERROR_OPERAND_INVALID:
case REP82_ERROR_OPERAND_SIZE:
case REP82_ERROR_EVEN_MOD_IN_OPND:
case REP88_ERROR_MESSAGE_MALFORMD:
// REP88_ERROR_INVALID_KEY // '82' CEX2A
// REP88_ERROR_OPERAND // '84' CEX2A
// REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A
/* Invalid input data. */
return -EINVAL;
case REP82_ERROR_MESSAGE_TYPE:
// REP88_ERROR_MESSAGE_TYPE // '20' CEX2A
/**
* To sent a message of the wrong type is a bug in the
* device driver. Warn about it, disable the device
* and then repeat the request.
*/
WARN_ON(1);
zdev->online = 0;
return -EAGAIN;
case REP82_ERROR_TRANSPORT_FAIL:
case REP82_ERROR_MACHINE_FAILURE:
// REP88_ERROR_MODULE_FAILURE // '10' CEX2A
/* If a card fails disable it and repeat the request. */
zdev->online = 0;
return -EAGAIN;
default:
PRINTKW("unknown type %02x reply code = %d\n",
ehdr->type, ehdr->reply_code);
zdev->online = 0;
return -EAGAIN; /* repeat the request on a different device. */
}
}
#endif /* _ZCRYPT_ERROR_H_ */
This diff is collapsed.
/*
* linux/drivers/s390/crypto/zcrypt_pcica.h
*
* zcrypt 2.0.0
*
* Copyright (C) 2001, 2006 IBM Corporation
* Author(s): Robert Burroughs
* Eric Rossman (edrossma@us.ibm.com)
*
* Hotplug & misc device support: Jochen Roehrig (roehrig@de.ibm.com)
* Major cleanup & driver split: Martin Schwidefsky <schwidefsky@de.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _ZCRYPT_PCICA_H_
#define _ZCRYPT_PCICA_H_
/**
* The type 4 message family is associated with a PCICA card.
*
* The four members of the family are described below.
*
* Note that all unsigned char arrays are right-justified and left-padded
* with zeroes.
*
* Note that all reserved fields must be zeroes.
*/
struct type4_hdr {
unsigned char reserved1;
unsigned char msg_type_code; /* 0x04 */
unsigned short msg_len;
unsigned char request_code; /* 0x40 */
unsigned char msg_fmt;
unsigned short reserved2;
} __attribute__((packed));
#define TYPE4_TYPE_CODE 0x04
#define TYPE4_REQU_CODE 0x40
#define TYPE4_SME_FMT 0x00
#define TYPE4_LME_FMT 0x10
#define TYPE4_SCR_FMT 0x40
#define TYPE4_LCR_FMT 0x50
/* Mod-Exp, with a small modulus */
struct type4_sme {
struct type4_hdr header;
unsigned char message[128];
unsigned char exponent[128];
unsigned char modulus[128];
} __attribute__((packed));
/* Mod-Exp, with a large modulus */
struct type4_lme {
struct type4_hdr header;
unsigned char message[256];
unsigned char exponent[256];
unsigned char modulus[256];
} __attribute__((packed));
/* CRT, with a small modulus */
struct type4_scr {
struct type4_hdr header;
unsigned char message[128];
unsigned char dp[72];
unsigned char dq[64];
unsigned char p[72];
unsigned char q[64];
unsigned char u[72];
} __attribute__((packed));
/* CRT, with a large modulus */
struct type4_lcr {
struct type4_hdr header;
unsigned char message[256];
unsigned char dp[136];
unsigned char dq[128];
unsigned char p[136];
unsigned char q[128];
unsigned char u[136];
} __attribute__((packed));
/**
* The type 84 response family is associated with a PCICA card.
*
* Note that all unsigned char arrays are right-justified and left-padded
* with zeroes.
*
* Note that all reserved fields must be zeroes.
*/
struct type84_hdr {
unsigned char reserved1;
unsigned char code;
unsigned short len;
unsigned char reserved2[4];
} __attribute__((packed));
#define TYPE84_RSP_CODE 0x84
int zcrypt_pcica_init(void);
void zcrypt_pcica_exit(void);
#endif /* _ZCRYPT_PCICA_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment