Commit cccd85bf authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Martin Schwidefsky

s390/zcrypt: Rework debug feature invocations.

Rework the debug feature calls and initialization.  There
are now two debug feature entries used by the zcrypt code.
The first is 'ap' with all the AP bus related stuff and the
second is 'zcrypt' with all the zcrypt and devices and
driver related entries. However, there isn't much traffic on
both debug features. The ap bus code emits only some debug
info and for zcrypt devices on appearance and disappearance
there is an entry written.

The new dbf invocations use the sprintf buffer layout,
whereas the old implementation used the ascii dbf buffer.
There are now 5*8=40 bytes used for each entry, resulting in
5 parameters per call. As the sprintf buffer needs a format
string the first parameter provides this and so up to 4 more
parameters can be used. Alltogehter the new layout should be
much more human readable for customers and test.
Signed-off-by: default avatarHarald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent bf9f3119
...@@ -47,9 +47,11 @@ ...@@ -47,9 +47,11 @@
#include <asm/facility.h> #include <asm/facility.h>
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/debugfs.h>
#include "ap_bus.h" #include "ap_bus.h"
#include "ap_asm.h" #include "ap_asm.h"
#include "ap_debug.h"
/* /*
* Module description. * Module description.
...@@ -81,6 +83,12 @@ LIST_HEAD(ap_card_list); ...@@ -81,6 +83,12 @@ LIST_HEAD(ap_card_list);
static struct ap_config_info *ap_configuration; static struct ap_config_info *ap_configuration;
static bool initialised; static bool initialised;
/*
* AP bus related debug feature things.
*/
static struct dentry *ap_dbf_root;
debug_info_t *ap_dbf_info;
/* /*
* Workqueue timer for bus rescan. * Workqueue timer for bus rescan.
*/ */
...@@ -568,6 +576,8 @@ static int ap_dev_resume(struct device *dev) ...@@ -568,6 +576,8 @@ static int ap_dev_resume(struct device *dev)
static void ap_bus_suspend(void) static void ap_bus_suspend(void)
{ {
AP_DBF(DBF_DEBUG, "ap_bus_suspend running\n");
ap_suspend_flag = 1; ap_suspend_flag = 1;
/* /*
* Disable scanning for devices, thus we do not want to scan * Disable scanning for devices, thus we do not want to scan
...@@ -603,6 +613,8 @@ static void ap_bus_resume(void) ...@@ -603,6 +613,8 @@ static void ap_bus_resume(void)
{ {
int rc; int rc;
AP_DBF(DBF_DEBUG, "ap_bus_resume running\n");
/* remove all queue devices */ /* remove all queue devices */
bus_for_each_dev(&ap_bus_type, NULL, NULL, bus_for_each_dev(&ap_bus_type, NULL, NULL,
__ap_queue_devices_unregister); __ap_queue_devices_unregister);
...@@ -742,6 +754,9 @@ static ssize_t ap_domain_store(struct bus_type *bus, ...@@ -742,6 +754,9 @@ static ssize_t ap_domain_store(struct bus_type *bus,
spin_lock_bh(&ap_domain_lock); spin_lock_bh(&ap_domain_lock);
ap_domain_index = domain; ap_domain_index = domain;
spin_unlock_bh(&ap_domain_lock); spin_unlock_bh(&ap_domain_lock);
AP_DBF(DBF_DEBUG, "store new default domain=%d\n", domain);
return count; return count;
} }
...@@ -964,6 +979,8 @@ static void ap_scan_bus(struct work_struct *unused) ...@@ -964,6 +979,8 @@ static void ap_scan_bus(struct work_struct *unused)
unsigned int functions = 0; unsigned int functions = 0;
int rc, id, dom, borked, domains; int rc, id, dom, borked, domains;
AP_DBF(DBF_DEBUG, "ap_scan_bus running\n");
ap_query_configuration(); ap_query_configuration();
if (ap_select_domain() != 0) if (ap_select_domain() != 0)
goto out; goto out;
...@@ -1129,6 +1146,23 @@ static struct reset_call ap_reset_call = { ...@@ -1129,6 +1146,23 @@ static struct reset_call ap_reset_call = {
.fn = ap_reset_all, .fn = ap_reset_all,
}; };
int __init ap_debug_init(void)
{
ap_dbf_root = debugfs_create_dir("ap", NULL);
ap_dbf_info = debug_register("ap", 1, 1,
DBF_MAX_SPRINTF_ARGS * sizeof(long));
debug_register_view(ap_dbf_info, &debug_sprintf_view);
debug_set_level(ap_dbf_info, DBF_ERR);
return 0;
}
void ap_debug_exit(void)
{
debugfs_remove(ap_dbf_root);
debug_unregister(ap_dbf_info);
}
/** /**
* ap_module_init(): The module initialization code. * ap_module_init(): The module initialization code.
* *
...@@ -1139,6 +1173,10 @@ int __init ap_module_init(void) ...@@ -1139,6 +1173,10 @@ int __init ap_module_init(void)
int max_domain_id; int max_domain_id;
int rc, i; int rc, i;
rc = ap_debug_init();
if (rc)
return rc;
if (ap_instructions_available() != 0) { if (ap_instructions_available() != 0) {
pr_warn("The hardware system does not support AP instructions\n"); pr_warn("The hardware system does not support AP instructions\n");
return -ENODEV; return -ENODEV;
...@@ -1266,6 +1304,8 @@ void ap_module_exit(void) ...@@ -1266,6 +1304,8 @@ void ap_module_exit(void)
unregister_reset_call(&ap_reset_call); unregister_reset_call(&ap_reset_call);
if (ap_using_interrupts()) if (ap_using_interrupts())
unregister_adapter_interrupt(&ap_airq); unregister_adapter_interrupt(&ap_airq);
ap_debug_exit();
} }
module_init(ap_module_init); module_init(ap_module_init);
......
/*
* Copyright IBM Corp. 2016
* Author(s): Harald Freudenberger <freude@de.ibm.com>
*/
#ifndef AP_DEBUG_H
#define AP_DEBUG_H
#include <asm/debug.h>
#define DBF_ERR 3 /* error conditions */
#define DBF_WARN 4 /* warning conditions */
#define DBF_INFO 5 /* informational */
#define DBF_DEBUG 6 /* for debugging only */
#define RC2ERR(rc) ((rc) ? DBF_ERR : DBF_INFO)
#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
#define DBF_MAX_SPRINTF_ARGS 5
#define AP_DBF(...) \
debug_sprintf_event(ap_dbf_info, ##__VA_ARGS__)
extern debug_info_t *ap_dbf_info;
int ap_debug_init(void);
void ap_debug_exit(void);
#endif /* AP_DEBUG_H */
...@@ -41,8 +41,8 @@ ...@@ -41,8 +41,8 @@
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <asm/debug.h> #include <asm/debug.h>
#include "zcrypt_debug.h"
#include "zcrypt_api.h" #include "zcrypt_api.h"
#include "zcrypt_debug.h"
#include "zcrypt_msgtype6.h" #include "zcrypt_msgtype6.h"
#include "zcrypt_msgtype50.h" #include "zcrypt_msgtype50.h"
...@@ -71,10 +71,9 @@ EXPORT_SYMBOL(zcrypt_rescan_req); ...@@ -71,10 +71,9 @@ EXPORT_SYMBOL(zcrypt_rescan_req);
static LIST_HEAD(zcrypt_ops_list); static LIST_HEAD(zcrypt_ops_list);
static struct dentry *debugfs_root; /* Zcrypt related debug feature stuff. */
debug_info_t *zcrypt_dbf_common; static struct dentry *zcrypt_dbf_root;
debug_info_t *zcrypt_dbf_devices; debug_info_t *zcrypt_dbf_info;
debug_info_t *zcrypt_dbf_cards;
/** /**
* Process a rescan of the transport layer. * Process a rescan of the transport layer.
...@@ -87,8 +86,8 @@ static inline int zcrypt_process_rescan(void) ...@@ -87,8 +86,8 @@ static inline int zcrypt_process_rescan(void)
atomic_set(&zcrypt_rescan_req, 0); atomic_set(&zcrypt_rescan_req, 0);
atomic_inc(&zcrypt_rescan_count); atomic_inc(&zcrypt_rescan_count);
ap_bus_force_rescan(); ap_bus_force_rescan();
ZCRYPT_DBF_COMMON(DBF_INFO, "rescan%07d", ZCRYPT_DBF(DBF_INFO, "rescan count=%07d",
atomic_inc_return(&zcrypt_rescan_count)); atomic_inc_return(&zcrypt_rescan_count));
return 1; return 1;
} }
return 0; return 0;
...@@ -1363,28 +1362,19 @@ void zcrypt_rng_device_remove(void) ...@@ -1363,28 +1362,19 @@ void zcrypt_rng_device_remove(void)
int __init zcrypt_debug_init(void) int __init zcrypt_debug_init(void)
{ {
debugfs_root = debugfs_create_dir("zcrypt", NULL); zcrypt_dbf_root = debugfs_create_dir("zcrypt", NULL);
zcrypt_dbf_info = debug_register("zcrypt", 1, 1,
zcrypt_dbf_common = debug_register("zcrypt_common", 1, 1, 16); DBF_MAX_SPRINTF_ARGS * sizeof(long));
debug_register_view(zcrypt_dbf_common, &debug_hex_ascii_view); debug_register_view(zcrypt_dbf_info, &debug_sprintf_view);
debug_set_level(zcrypt_dbf_common, DBF_ERR); debug_set_level(zcrypt_dbf_info, DBF_ERR);
zcrypt_dbf_devices = debug_register("zcrypt_devices", 1, 1, 16);
debug_register_view(zcrypt_dbf_devices, &debug_hex_ascii_view);
debug_set_level(zcrypt_dbf_devices, DBF_ERR);
zcrypt_dbf_cards = debug_register("zcrypt_cards", 1, 1, 16);
debug_register_view(zcrypt_dbf_cards, &debug_hex_ascii_view);
debug_set_level(zcrypt_dbf_cards, DBF_ERR);
return 0; return 0;
} }
void zcrypt_debug_exit(void) void zcrypt_debug_exit(void)
{ {
debugfs_remove(debugfs_root); debugfs_remove(zcrypt_dbf_root);
debug_unregister(zcrypt_dbf_common); debug_unregister(zcrypt_dbf_info);
debug_unregister(zcrypt_dbf_devices);
} }
/** /**
...@@ -1434,9 +1424,9 @@ void __exit zcrypt_api_exit(void) ...@@ -1434,9 +1424,9 @@ void __exit zcrypt_api_exit(void)
{ {
remove_proc_entry("driver/z90crypt", NULL); remove_proc_entry("driver/z90crypt", NULL);
misc_deregister(&zcrypt_misc_device); misc_deregister(&zcrypt_misc_device);
zcrypt_debug_exit();
zcrypt_msgtype6_exit(); zcrypt_msgtype6_exit();
zcrypt_msgtype50_exit(); zcrypt_msgtype50_exit();
zcrypt_debug_exit();
} }
module_init(zcrypt_api_init); module_init(zcrypt_api_init);
......
...@@ -132,8 +132,6 @@ struct zcrypt_card { ...@@ -132,8 +132,6 @@ struct zcrypt_card {
atomic_t load; /* Utilization of the crypto device */ atomic_t load; /* Utilization of the crypto device */
int request_count; /* # current requests. */ int request_count; /* # current requests. */
debug_info_t *dbf_area; /* debugging */
}; };
struct zcrypt_queue { struct zcrypt_queue {
...@@ -149,8 +147,6 @@ struct zcrypt_queue { ...@@ -149,8 +147,6 @@ struct zcrypt_queue {
int request_count; /* # current requests. */ int request_count; /* # current requests. */
struct ap_message reply; /* Per-device reply structure. */ struct ap_message reply; /* Per-device reply structure. */
debug_info_t *dbf_area; /* debugging */
}; };
/* transport layer rescanning */ /* transport layer rescanning */
...@@ -160,10 +156,6 @@ extern spinlock_t zcrypt_list_lock; ...@@ -160,10 +156,6 @@ extern spinlock_t zcrypt_list_lock;
extern int zcrypt_device_count; extern int zcrypt_device_count;
extern struct list_head zcrypt_card_list; extern struct list_head zcrypt_card_list;
extern debug_info_t *zcrypt_dbf_common;
extern debug_info_t *zcrypt_dbf_devices;
extern debug_info_t *zcrypt_dbf_cards;
#define for_each_zcrypt_card(_zc) \ #define for_each_zcrypt_card(_zc) \
list_for_each_entry(_zc, &zcrypt_card_list, list) list_for_each_entry(_zc, &zcrypt_card_list, list)
......
...@@ -79,7 +79,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev, ...@@ -79,7 +79,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev,
zc->online = online; zc->online = online;
id = zc->card->id; id = zc->card->id;
ZCRYPT_DBF_DEV(DBF_INFO, zc, "card%02xo%dman", id, online);
ZCRYPT_DBF(DBF_INFO, "card=%02x online=%d\n", id, online);
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
list_for_each_entry(zq, &zc->zqueues, list) list_for_each_entry(zq, &zc->zqueues, list)
zcrypt_queue_force_online(zq, online); zcrypt_queue_force_online(zq, online);
...@@ -109,7 +111,6 @@ struct zcrypt_card *zcrypt_card_alloc(void) ...@@ -109,7 +111,6 @@ struct zcrypt_card *zcrypt_card_alloc(void)
return NULL; return NULL;
INIT_LIST_HEAD(&zc->list); INIT_LIST_HEAD(&zc->list);
INIT_LIST_HEAD(&zc->zqueues); INIT_LIST_HEAD(&zc->zqueues);
zc->dbf_area = zcrypt_dbf_cards;
kref_init(&zc->refcount); kref_init(&zc->refcount);
return zc; return zc;
} }
...@@ -160,6 +161,9 @@ int zcrypt_card_register(struct zcrypt_card *zc) ...@@ -160,6 +161,9 @@ int zcrypt_card_register(struct zcrypt_card *zc)
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
zc->online = 1; zc->online = 1;
ZCRYPT_DBF(DBF_INFO, "card=%02x register online=1\n", zc->card->id);
return rc; return rc;
} }
EXPORT_SYMBOL(zcrypt_card_register); EXPORT_SYMBOL(zcrypt_card_register);
...@@ -172,6 +176,8 @@ EXPORT_SYMBOL(zcrypt_card_register); ...@@ -172,6 +176,8 @@ EXPORT_SYMBOL(zcrypt_card_register);
*/ */
void zcrypt_card_unregister(struct zcrypt_card *zc) void zcrypt_card_unregister(struct zcrypt_card *zc)
{ {
ZCRYPT_DBF(DBF_INFO, "card=%02x unregister\n", zc->card->id);
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
list_del_init(&zc->list); list_del_init(&zc->list);
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
......
/* /*
* Copyright IBM Corp. 2012 * Copyright IBM Corp. 2016
* Author(s): Holger Dengler (hd@linux.vnet.ibm.com) * Author(s): Holger Dengler (hd@linux.vnet.ibm.com)
* Harald Freudenberger <freude@de.ibm.com>
*/ */
#ifndef ZCRYPT_DEBUG_H #ifndef ZCRYPT_DEBUG_H
#define ZCRYPT_DEBUG_H #define ZCRYPT_DEBUG_H
#include <asm/debug.h> #include <asm/debug.h>
#include "zcrypt_api.h"
/* that gives us 15 characters in the text event views */ #define DBF_ERR 3 /* error conditions */
#define ZCRYPT_DBF_LEN 16 #define DBF_WARN 4 /* warning conditions */
#define DBF_INFO 5 /* informational */
#define DBF_ERR 3 /* error conditions */ #define DBF_DEBUG 6 /* for debugging only */
#define DBF_WARN 4 /* warning conditions */
#define DBF_INFO 6 /* informational */
#define RC2ERR(rc) ((rc) ? DBF_ERR : DBF_INFO)
#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO) #define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
#define ZCRYPT_DBF_COMMON(level, text...) \ #define DBF_MAX_SPRINTF_ARGS 5
do { \
if (debug_level_enabled(zcrypt_dbf_common, level)) { \ #define ZCRYPT_DBF(...) \
char debug_buffer[ZCRYPT_DBF_LEN]; \ debug_sprintf_event(zcrypt_dbf_info, ##__VA_ARGS__)
snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
debug_text_event(zcrypt_dbf_common, level, \ extern debug_info_t *zcrypt_dbf_info;
debug_buffer); \
} \
} while (0)
#define ZCRYPT_DBF_DEVICES(level, text...) \
do { \
if (debug_level_enabled(zcrypt_dbf_devices, level)) { \
char debug_buffer[ZCRYPT_DBF_LEN]; \
snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
debug_text_event(zcrypt_dbf_devices, level, \
debug_buffer); \
} \
} while (0)
#define ZCRYPT_DBF_DEV(level, device, text...) \
do { \
if (debug_level_enabled(device->dbf_area, level)) { \
char debug_buffer[ZCRYPT_DBF_LEN]; \
snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
debug_text_event(device->dbf_area, level, \
debug_buffer); \
} \
} while (0)
int zcrypt_debug_init(void); int zcrypt_debug_init(void);
void zcrypt_debug_exit(void); void zcrypt_debug_exit(void);
......
...@@ -93,6 +93,8 @@ static inline int convert_error(struct zcrypt_queue *zq, ...@@ -93,6 +93,8 @@ static inline int convert_error(struct zcrypt_queue *zq,
struct ap_message *reply) struct ap_message *reply)
{ {
struct error_hdr *ehdr = reply->message; struct error_hdr *ehdr = reply->message;
int card = AP_QID_CARD(zq->queue->qid);
int queue = AP_QID_QUEUE(zq->queue->qid);
switch (ehdr->reply_code) { switch (ehdr->reply_code) {
case REP82_ERROR_OPERAND_INVALID: case REP82_ERROR_OPERAND_INVALID:
...@@ -105,6 +107,9 @@ static inline int convert_error(struct zcrypt_queue *zq, ...@@ -105,6 +107,9 @@ static inline int convert_error(struct zcrypt_queue *zq,
// REP88_ERROR_OPERAND // '84' CEX2A // REP88_ERROR_OPERAND // '84' CEX2A
// REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A
/* Invalid input data. */ /* Invalid input data. */
ZCRYPT_DBF(DBF_WARN,
"device=%02x.%04x reply=0x%02x => rc=EINVAL\n",
card, queue, ehdr->reply_code);
return -EINVAL; return -EINVAL;
case REP82_ERROR_MESSAGE_TYPE: case REP82_ERROR_MESSAGE_TYPE:
// REP88_ERROR_MESSAGE_TYPE // '20' CEX2A // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A
...@@ -116,12 +121,10 @@ static inline int convert_error(struct zcrypt_queue *zq, ...@@ -116,12 +121,10 @@ static inline int convert_error(struct zcrypt_queue *zq,
atomic_set(&zcrypt_rescan_req, 1); atomic_set(&zcrypt_rescan_req, 1);
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), card, queue);
AP_QID_QUEUE(zq->queue->qid)); ZCRYPT_DBF(DBF_ERR,
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_CARD(zq->queue->qid), card, queue, ehdr->reply_code);
AP_QID_QUEUE(zq->queue->qid), zq->online,
ehdr->reply_code);
return -EAGAIN; return -EAGAIN;
case REP82_ERROR_TRANSPORT_FAIL: case REP82_ERROR_TRANSPORT_FAIL:
case REP82_ERROR_MACHINE_FAILURE: case REP82_ERROR_MACHINE_FAILURE:
...@@ -130,22 +133,18 @@ static inline int convert_error(struct zcrypt_queue *zq, ...@@ -130,22 +133,18 @@ static inline int convert_error(struct zcrypt_queue *zq,
atomic_set(&zcrypt_rescan_req, 1); atomic_set(&zcrypt_rescan_req, 1);
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), card, queue);
AP_QID_QUEUE(zq->queue->qid)); ZCRYPT_DBF(DBF_ERR,
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_CARD(zq->queue->qid), card, queue, ehdr->reply_code);
AP_QID_QUEUE(zq->queue->qid), zq->online,
ehdr->reply_code);
return -EAGAIN; return -EAGAIN;
default: default:
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), card, queue);
AP_QID_QUEUE(zq->queue->qid)); ZCRYPT_DBF(DBF_ERR,
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_CARD(zq->queue->qid), card, queue, ehdr->reply_code);
AP_QID_QUEUE(zq->queue->qid), zq->online,
ehdr->reply_code);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
......
...@@ -367,11 +367,11 @@ static int convert_type80(struct zcrypt_queue *zq, ...@@ -367,11 +367,11 @@ static int convert_type80(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x code=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online, t80h->code); AP_QID_QUEUE(zq->queue->qid),
t80h->code);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
if (zq->zcard->user_space_type == ZCRYPT_CEX2A) if (zq->zcard->user_space_type == ZCRYPT_CEX2A)
...@@ -390,7 +390,9 @@ static int convert_response(struct zcrypt_queue *zq, ...@@ -390,7 +390,9 @@ static int convert_response(struct zcrypt_queue *zq,
unsigned int outputdatalength) unsigned int outputdatalength)
{ {
/* Response type byte is the second byte in the response. */ /* Response type byte is the second byte in the response. */
switch (((unsigned char *) reply->message)[1]) { unsigned char rtype = ((unsigned char *) reply->message)[1];
switch (rtype) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
case TYPE88_RSP_CODE: case TYPE88_RSP_CODE:
return convert_error(zq, reply); return convert_error(zq, reply);
...@@ -402,10 +404,11 @@ static int convert_response(struct zcrypt_queue *zq, ...@@ -402,10 +404,11 @@ static int convert_response(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online); AP_QID_QUEUE(zq->queue->qid),
(unsigned int) rtype);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
......
...@@ -638,30 +638,37 @@ static int convert_type86_ica(struct zcrypt_queue *zq, ...@@ -638,30 +638,37 @@ static int convert_type86_ica(struct zcrypt_queue *zq,
service_rc = msg->cprbx.ccp_rtcode; service_rc = msg->cprbx.ccp_rtcode;
if (unlikely(service_rc != 0)) { if (unlikely(service_rc != 0)) {
service_rs = msg->cprbx.ccp_rscode; service_rs = msg->cprbx.ccp_rscode;
if (service_rc == 8 && service_rs == 66) if ((service_rc == 8 && service_rs == 66) ||
return -EINVAL; (service_rc == 8 && service_rs == 65) ||
if (service_rc == 8 && service_rs == 65) (service_rc == 8 && service_rs == 72) ||
return -EINVAL; (service_rc == 8 && service_rs == 770) ||
if (service_rc == 8 && service_rs == 770) (service_rc == 12 && service_rs == 769)) {
ZCRYPT_DBF(DBF_DEBUG,
"device=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n",
AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid),
(int) service_rc, (int) service_rs);
return -EINVAL; return -EINVAL;
}
if (service_rc == 8 && service_rs == 783) { if (service_rc == 8 && service_rs == 783) {
zq->zcard->min_mod_size = zq->zcard->min_mod_size =
PCIXCC_MIN_MOD_SIZE_OLD; PCIXCC_MIN_MOD_SIZE_OLD;
ZCRYPT_DBF(DBF_DEBUG,
"device=%02x.%04x rc/rs=%d/%d => rc=EAGAIN\n",
AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid),
(int) service_rc, (int) service_rs);
return -EAGAIN; return -EAGAIN;
} }
if (service_rc == 12 && service_rs == 769)
return -EINVAL;
if (service_rc == 8 && service_rs == 72)
return -EINVAL;
zq->online = 0; zq->online = 0;
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online, AP_QID_QUEUE(zq->queue->qid),
msg->hdr.reply_code); (int) service_rc, (int) service_rs);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
data = msg->text; data = msg->text;
...@@ -776,8 +783,7 @@ static int convert_response_ica(struct zcrypt_queue *zq, ...@@ -776,8 +783,7 @@ static int convert_response_ica(struct zcrypt_queue *zq,
{ {
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->message;
/* Response type byte is the second byte in the response. */ switch (msg->hdr.type) {
switch (((unsigned char *) reply->message)[1]) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
case TYPE88_RSP_CODE: case TYPE88_RSP_CODE:
return convert_error(zq, reply); return convert_error(zq, reply);
...@@ -803,10 +809,11 @@ static int convert_response_ica(struct zcrypt_queue *zq, ...@@ -803,10 +809,11 @@ static int convert_response_ica(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online); AP_QID_QUEUE(zq->queue->qid),
(int) msg->hdr.type);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
...@@ -817,8 +824,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, ...@@ -817,8 +824,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
{ {
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->message;
/* Response type byte is the second byte in the response. */ switch (msg->hdr.type) {
switch (((unsigned char *) reply->message)[1]) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
case TYPE88_RSP_CODE: case TYPE88_RSP_CODE:
xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
...@@ -838,10 +844,11 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, ...@@ -838,10 +844,11 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online); AP_QID_QUEUE(zq->queue->qid),
(int) msg->hdr.type);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
...@@ -851,8 +858,7 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq, ...@@ -851,8 +858,7 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq,
{ {
struct type86_ep11_reply *msg = reply->message; struct type86_ep11_reply *msg = reply->message;
/* Response type byte is the second byte in the response. */ switch (msg->hdr.type) {
switch (((unsigned char *)reply->message)[1]) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
case TYPE87_RSP_CODE: case TYPE87_RSP_CODE:
return convert_error(zq, reply); return convert_error(zq, reply);
...@@ -867,10 +873,11 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq, ...@@ -867,10 +873,11 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online); AP_QID_QUEUE(zq->queue->qid),
(int) msg->hdr.type);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
...@@ -897,10 +904,11 @@ static int convert_response_rng(struct zcrypt_queue *zq, ...@@ -897,10 +904,11 @@ static int convert_response_rng(struct zcrypt_queue *zq,
pr_err("Cryptographic device %02x.%04x failed and was set offline\n", pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
AP_QID_CARD(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid)); AP_QID_QUEUE(zq->queue->qid));
ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", ZCRYPT_DBF(DBF_ERR,
AP_QID_CARD(zq->queue->qid), "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid),
zq->online); AP_QID_QUEUE(zq->queue->qid),
(int) msg->hdr.type);
return -EAGAIN; /* repeat the request on a different device. */ return -EAGAIN; /* repeat the request on a different device. */
} }
} }
......
...@@ -70,9 +70,12 @@ static ssize_t zcrypt_queue_online_store(struct device *dev, ...@@ -70,9 +70,12 @@ static ssize_t zcrypt_queue_online_store(struct device *dev,
if (online && !zc->online) if (online && !zc->online)
return -EINVAL; return -EINVAL;
zq->online = online; zq->online = online;
ZCRYPT_DBF_DEV(DBF_INFO, zq, "dev%02x%04xo%dman",
AP_QID_CARD(zq->queue->qid), ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x online=%d\n",
AP_QID_QUEUE(zq->queue->qid), online); AP_QID_CARD(zq->queue->qid),
AP_QID_QUEUE(zq->queue->qid),
online);
if (!online) if (!online)
ap_flush_queue(zq->queue); ap_flush_queue(zq->queue);
return count; return count;
...@@ -109,7 +112,6 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t max_response_size) ...@@ -109,7 +112,6 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t max_response_size)
goto out_free; goto out_free;
zq->reply.length = max_response_size; zq->reply.length = max_response_size;
INIT_LIST_HEAD(&zq->list); INIT_LIST_HEAD(&zq->list);
zq->dbf_area = zcrypt_dbf_devices;
kref_init(&zq->refcount); kref_init(&zq->refcount);
return zq; return zq;
...@@ -161,10 +163,10 @@ int zcrypt_queue_register(struct zcrypt_queue *zq) ...@@ -161,10 +163,10 @@ int zcrypt_queue_register(struct zcrypt_queue *zq)
zcrypt_card_get(zc); zcrypt_card_get(zc);
zq->zcard = zc; zq->zcard = zc;
zq->online = 1; /* New devices are online by default. */ zq->online = 1; /* New devices are online by default. */
ZCRYPT_DBF_DEV(DBF_INFO, zq, "dev%02x%04xo%dreg",
AP_QID_CARD(zq->queue->qid), ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x register online=1\n",
AP_QID_QUEUE(zq->queue->qid), AP_QID_CARD(zq->queue->qid), AP_QID_QUEUE(zq->queue->qid));
zq->online);
list_add_tail(&zq->list, &zc->zqueues); list_add_tail(&zq->list, &zc->zqueues);
zcrypt_device_count++; zcrypt_device_count++;
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
...@@ -205,6 +207,9 @@ void zcrypt_queue_unregister(struct zcrypt_queue *zq) ...@@ -205,6 +207,9 @@ void zcrypt_queue_unregister(struct zcrypt_queue *zq)
{ {
struct zcrypt_card *zc; struct zcrypt_card *zc;
ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x unregister\n",
AP_QID_CARD(zq->queue->qid), AP_QID_QUEUE(zq->queue->qid));
zc = zq->zcard; zc = zq->zcard;
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
list_del_init(&zq->list); list_del_init(&zq->list);
......
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