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

s390/zcrypt: Support up to 256 crypto adapters.

There was an artificial restriction on the card/adapter id
to only 6 bits but all the AP commands do support adapter
ids with 8 bit. This patch removes this restriction to 64
adapters and now up to 256 adapter can get addressed.

Some of the ioctl calls work on the max number of cards
possible (which was 64). These ioctls are now deprecated
but still supported. All the defines, structs and ioctl
interface declarations have been kept for compabibility.
There are now new ioctls (and defines for these) with an
additional '2' appended which provide the extended versions
with 256 cards supported.
Signed-off-by: default avatarHarald Freudenberger <freude@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 71cbbff8
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
*/ */
typedef unsigned int ap_qid_t; typedef unsigned int ap_qid_t;
#define AP_MKQID(_card, _queue) (((_card) & 63) << 8 | ((_queue) & 255)) #define AP_MKQID(_card, _queue) (((_card) & 0xff) << 8 | ((_queue) & 0xff))
#define AP_QID_CARD(_qid) (((_qid) >> 8) & 63) #define AP_QID_CARD(_qid) (((_qid) >> 8) & 0xff)
#define AP_QID_QUEUE(_qid) ((_qid) & 255) #define AP_QID_QUEUE(_qid) ((_qid) & 0xff)
/** /**
* struct ap_queue_status - Holds the AP queue status. * struct ap_queue_status - Holds the AP queue status.
......
...@@ -203,9 +203,9 @@ struct ep11_urb { ...@@ -203,9 +203,9 @@ struct ep11_urb {
} __attribute__((packed)); } __attribute__((packed));
/** /**
* struct zcrypt_device_status * struct zcrypt_device_status_ext
* @hwtype: raw hardware type * @hwtype: raw hardware type
* @qid: 6 bit device index, 8 bit domain * @qid: 8 bit device index, 8 bit domain
* @functions: AP device function bit field 'abcdef' * @functions: AP device function bit field 'abcdef'
* a, b, c = reserved * a, b, c = reserved
* d = CCA coprocessor * d = CCA coprocessor
...@@ -214,28 +214,23 @@ struct ep11_urb { ...@@ -214,28 +214,23 @@ struct ep11_urb {
* @online online status * @online online status
* @reserved reserved * @reserved reserved
*/ */
struct zcrypt_device_status { struct zcrypt_device_status_ext {
unsigned int hwtype:8; unsigned int hwtype:8;
unsigned int qid:14; unsigned int qid:16;
unsigned int online:1; unsigned int online:1;
unsigned int functions:6; unsigned int functions:6;
unsigned int reserved:3; unsigned int reserved:1;
}; };
#define MAX_ZDEV_CARDIDS 64 #define MAX_ZDEV_CARDIDS_EXT 256
#define MAX_ZDEV_DOMAINS 256 #define MAX_ZDEV_DOMAINS_EXT 256
/** /* Maximum number of zcrypt devices */
* Maximum number of zcrypt devices #define MAX_ZDEV_ENTRIES_EXT (MAX_ZDEV_CARDIDS_EXT * MAX_ZDEV_DOMAINS_EXT)
*/
#define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS)
/** /* Device matrix of all zcrypt devices */
* zcrypt_device_matrix struct zcrypt_device_matrix_ext {
* Device matrix of all zcrypt devices struct zcrypt_device_status_ext device[MAX_ZDEV_ENTRIES_EXT];
*/
struct zcrypt_device_matrix {
struct zcrypt_device_status device[MAX_ZDEV_ENTRIES];
}; };
#define AUTOSELECT ((unsigned int)0xFFFFFFFF) #define AUTOSELECT ((unsigned int)0xFFFFFFFF)
...@@ -270,39 +265,35 @@ struct zcrypt_device_matrix { ...@@ -270,39 +265,35 @@ struct zcrypt_device_matrix {
* ZSENDEP11CPRB * ZSENDEP11CPRB
* Send an arbitrary EP11 CPRB to an EP11 coprocessor crypto card. * Send an arbitrary EP11 CPRB to an EP11 coprocessor crypto card.
* *
* Z90STAT_STATUS_MASK * ZCRYPT_DEVICE_STATUS
* Return an 64 element array of unsigned chars for the status of * The given struct zcrypt_device_matrix_ext is updated with
* all devices. * status information for each currently known apqn.
*
* ZCRYPT_STATUS_MASK
* Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned chars for the
* status of all devices.
* 0x01: PCICA * 0x01: PCICA
* 0x02: PCICC * 0x02: PCICC
* 0x03: PCIXCC_MCL2 * 0x03: PCIXCC_MCL2
* 0x04: PCIXCC_MCL3 * 0x04: PCIXCC_MCL3
* 0x05: CEX2C * 0x05: CEX2C
* 0x06: CEX2A * 0x06: CEX2A
* 0x0d: device is disabled via the proc filesystem * 0x07: CEX3C
* * 0x08: CEX3A
* Z90STAT_QDEPTH_MASK * 0x0a: CEX4
* Return an 64 element array of unsigned chars for the queue * 0x0b: CEX5
* depth of all devices. * 0x0c: CEX6
* * 0x0d: device is disabled
* Z90STAT_PERDEV_REQCNT
* Return an 64 element array of unsigned integers for the number
* of successfully completed requests per device since the device
* was detected and made available.
* *
* Z90STAT_REQUESTQ_COUNT * ZCRYPT_QDEPTH_MASK
* Return an integer count of the number of entries waiting to be * Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned chars for the
* sent to a device. * queue depth of all devices.
* *
* Z90STAT_PENDINGQ_COUNT * ZCRYPT_PERDEV_REQCNT
* Return an integer count of the number of entries sent to all * Return an MAX_ZDEV_CARDIDS_EXT element array of unsigned integers for
* devices awaiting the reply. * the number of successfully completed requests per device since the
* device was detected and made available.
* *
* Z90STAT_TOTALOPEN_COUNT
* Return an integer count of the number of open file handles.
*
* Z90STAT_DOMAIN_INDEX
* Return the integer value of the Cryptographic Domain.
*/ */
/** /**
...@@ -312,15 +303,56 @@ struct zcrypt_device_matrix { ...@@ -312,15 +303,56 @@ struct zcrypt_device_matrix {
#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0) #define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
#define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0) #define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
#define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0) #define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
#define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT])
#define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT])
#define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT])
/*
* Only deprecated defines, structs and ioctls below this line.
*/
/* Deprecated: use MAX_ZDEV_CARDIDS_EXT */
#define MAX_ZDEV_CARDIDS 64
/* Deprecated: use MAX_ZDEV_DOMAINS_EXT */
#define MAX_ZDEV_DOMAINS 256
/* Deprecated: use MAX_ZDEV_ENTRIES_EXT */
#define MAX_ZDEV_ENTRIES (MAX_ZDEV_CARDIDS * MAX_ZDEV_DOMAINS)
/* Deprecated: use struct zcrypt_device_status_ext */
struct zcrypt_device_status {
unsigned int hwtype:8;
unsigned int qid:14;
unsigned int online:1;
unsigned int functions:6;
unsigned int reserved:3;
};
/* Deprecated: use struct zcrypt_device_matrix_ext */
struct zcrypt_device_matrix {
struct zcrypt_device_status device[MAX_ZDEV_ENTRIES];
};
/* Deprecated: use ZCRYPT_DEVICE_STATUS */
#define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0) #define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
/* Deprecated: use ZCRYPT_STATUS_MASK */
#define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
/* Deprecated: use ZCRYPT_QDEPTH_MASK */
#define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64])
/* Deprecated: use ZCRYPT_PERDEV_REQCNT */
#define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64])
/* Status ioctl calls */ /* Deprecated: use sysfs to query these values */
#define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int) #define Z90STAT_REQUESTQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x44, int)
#define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int) #define Z90STAT_PENDINGQ_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x45, int)
#define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int) #define Z90STAT_TOTALOPEN_COUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x46, int)
#define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int) #define Z90STAT_DOMAIN_INDEX _IOR(ZCRYPT_IOCTL_MAGIC, 0x47, int)
#define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
#define Z90STAT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x49, char[64]) /*
#define Z90STAT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x4a, int[64]) * The ioctl number ranges 0x40 - 0x42 and 0x4b - 0x4e had been used in the
* past, don't assign new ioctls for these.
*/
#endif /* __ASM_S390_ZCRYPT_H */ #endif /* __ASM_S390_ZCRYPT_H */
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <asm/ap.h> #include <asm/ap.h>
#define AP_DEVICES 64 /* Number of AP devices. */ #define AP_DEVICES 256 /* Number of AP devices. */
#define AP_DOMAINS 256 /* Number of AP domains. */ #define AP_DOMAINS 256 /* Number of AP domains. */
#define AP_RESET_TIMEOUT (HZ*0.7) /* Time in ticks for reset timeouts. */ #define AP_RESET_TIMEOUT (HZ*0.7) /* Time in ticks for reset timeouts. */
#define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */ #define AP_CONFIG_TIME 30 /* Time in seconds between AP bus rescans. */
......
...@@ -889,7 +889,7 @@ int pkey_findcard(const struct pkey_seckey *seckey, ...@@ -889,7 +889,7 @@ int pkey_findcard(const struct pkey_seckey *seckey,
u16 *pcardnr, u16 *pdomain, int verify) u16 *pcardnr, u16 *pdomain, int verify)
{ {
struct secaeskeytoken *t = (struct secaeskeytoken *) seckey; struct secaeskeytoken *t = (struct secaeskeytoken *) seckey;
struct zcrypt_device_matrix *device_matrix; struct zcrypt_device_status_ext *device_status;
u16 card, dom; u16 card, dom;
u64 mkvp[2]; u64 mkvp[2];
int i, rc, oi = -1; int i, rc, oi = -1;
...@@ -899,18 +899,19 @@ int pkey_findcard(const struct pkey_seckey *seckey, ...@@ -899,18 +899,19 @@ int pkey_findcard(const struct pkey_seckey *seckey,
return -EINVAL; return -EINVAL;
/* fetch status of all crypto cards */ /* fetch status of all crypto cards */
device_matrix = kmalloc(sizeof(struct zcrypt_device_matrix), device_status = kmalloc(MAX_ZDEV_ENTRIES_EXT
* sizeof(struct zcrypt_device_status_ext),
GFP_KERNEL); GFP_KERNEL);
if (!device_matrix) if (!device_status)
return -ENOMEM; return -ENOMEM;
zcrypt_device_status_mask(device_matrix); zcrypt_device_status_mask_ext(device_status);
/* walk through all crypto cards */ /* walk through all crypto cards */
for (i = 0; i < MAX_ZDEV_ENTRIES; i++) { for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) {
card = AP_QID_CARD(device_matrix->device[i].qid); card = AP_QID_CARD(device_status[i].qid);
dom = AP_QID_QUEUE(device_matrix->device[i].qid); dom = AP_QID_QUEUE(device_status[i].qid);
if (device_matrix->device[i].online && if (device_status[i].online &&
device_matrix->device[i].functions & 0x04) { device_status[i].functions & 0x04) {
/* an enabled CCA Coprocessor card */ /* an enabled CCA Coprocessor card */
/* try cached mkvp */ /* try cached mkvp */
if (mkvp_cache_fetch(card, dom, mkvp) == 0 && if (mkvp_cache_fetch(card, dom, mkvp) == 0 &&
...@@ -930,14 +931,14 @@ int pkey_findcard(const struct pkey_seckey *seckey, ...@@ -930,14 +931,14 @@ int pkey_findcard(const struct pkey_seckey *seckey,
mkvp_cache_scrub(card, dom); mkvp_cache_scrub(card, dom);
} }
} }
if (i >= MAX_ZDEV_ENTRIES) { if (i >= MAX_ZDEV_ENTRIES_EXT) {
/* nothing found, so this time without cache */ /* nothing found, so this time without cache */
for (i = 0; i < MAX_ZDEV_ENTRIES; i++) { for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) {
if (!(device_matrix->device[i].online && if (!(device_status[i].online &&
device_matrix->device[i].functions & 0x04)) device_status[i].functions & 0x04))
continue; continue;
card = AP_QID_CARD(device_matrix->device[i].qid); card = AP_QID_CARD(device_status[i].qid);
dom = AP_QID_QUEUE(device_matrix->device[i].qid); dom = AP_QID_QUEUE(device_status[i].qid);
/* fresh fetch mkvp from adapter */ /* fresh fetch mkvp from adapter */
if (fetch_mkvp(card, dom, mkvp) == 0) { if (fetch_mkvp(card, dom, mkvp) == 0) {
mkvp_cache_update(card, dom, mkvp); mkvp_cache_update(card, dom, mkvp);
...@@ -947,13 +948,13 @@ int pkey_findcard(const struct pkey_seckey *seckey, ...@@ -947,13 +948,13 @@ int pkey_findcard(const struct pkey_seckey *seckey,
oi = i; oi = i;
} }
} }
if (i >= MAX_ZDEV_ENTRIES && oi >= 0) { if (i >= MAX_ZDEV_ENTRIES_EXT && oi >= 0) {
/* old mkvp matched, use this card then */ /* old mkvp matched, use this card then */
card = AP_QID_CARD(device_matrix->device[oi].qid); card = AP_QID_CARD(device_status[oi].qid);
dom = AP_QID_QUEUE(device_matrix->device[oi].qid); dom = AP_QID_QUEUE(device_status[oi].qid);
} }
} }
if (i < MAX_ZDEV_ENTRIES || oi >= 0) { if (i < MAX_ZDEV_ENTRIES_EXT || oi >= 0) {
if (pcardnr) if (pcardnr)
*pcardnr = card; *pcardnr = card;
if (pdomain) if (pdomain)
...@@ -962,7 +963,7 @@ int pkey_findcard(const struct pkey_seckey *seckey, ...@@ -962,7 +963,7 @@ int pkey_findcard(const struct pkey_seckey *seckey,
} else } else
rc = -ENODEV; rc = -ENODEV;
kfree(device_matrix); kfree(device_status);
return rc; return rc;
} }
EXPORT_SYMBOL(pkey_findcard); EXPORT_SYMBOL(pkey_findcard);
......
...@@ -605,19 +605,24 @@ static long zcrypt_rng(char *buffer) ...@@ -605,19 +605,24 @@ static long zcrypt_rng(char *buffer)
return rc; return rc;
} }
void zcrypt_device_status_mask(struct zcrypt_device_matrix *matrix) static void zcrypt_device_status_mask(struct zcrypt_device_status *devstatus)
{ {
struct zcrypt_card *zc; struct zcrypt_card *zc;
struct zcrypt_queue *zq; struct zcrypt_queue *zq;
struct zcrypt_device_status *stat; struct zcrypt_device_status *stat;
int card, queue;
memset(devstatus, 0, MAX_ZDEV_ENTRIES
* sizeof(struct zcrypt_device_status));
memset(matrix, 0, sizeof(*matrix));
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
for_each_zcrypt_card(zc) { for_each_zcrypt_card(zc) {
for_each_zcrypt_queue(zq, zc) { for_each_zcrypt_queue(zq, zc) {
stat = matrix->device; card = AP_QID_CARD(zq->queue->qid);
stat += AP_QID_CARD(zq->queue->qid) * MAX_ZDEV_DOMAINS; if (card >= MAX_ZDEV_CARDIDS)
stat += AP_QID_QUEUE(zq->queue->qid); continue;
queue = AP_QID_QUEUE(zq->queue->qid);
stat = &devstatus[card * AP_DOMAINS + queue];
stat->hwtype = zc->card->ap_dev.device_type; stat->hwtype = zc->card->ap_dev.device_type;
stat->functions = zc->card->functions >> 26; stat->functions = zc->card->functions >> 26;
stat->qid = zq->queue->qid; stat->qid = zq->queue->qid;
...@@ -626,40 +631,70 @@ void zcrypt_device_status_mask(struct zcrypt_device_matrix *matrix) ...@@ -626,40 +631,70 @@ void zcrypt_device_status_mask(struct zcrypt_device_matrix *matrix)
} }
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
} }
EXPORT_SYMBOL(zcrypt_device_status_mask);
static void zcrypt_status_mask(char status[AP_DEVICES]) void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus)
{ {
struct zcrypt_card *zc; struct zcrypt_card *zc;
struct zcrypt_queue *zq; struct zcrypt_queue *zq;
struct zcrypt_device_status_ext *stat;
int card, queue;
memset(devstatus, 0, MAX_ZDEV_ENTRIES_EXT
* sizeof(struct zcrypt_device_status_ext));
memset(status, 0, sizeof(char) * AP_DEVICES);
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
for_each_zcrypt_card(zc) { for_each_zcrypt_card(zc) {
for_each_zcrypt_queue(zq, zc) { for_each_zcrypt_queue(zq, zc) {
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) card = AP_QID_CARD(zq->queue->qid);
queue = AP_QID_QUEUE(zq->queue->qid);
stat = &devstatus[card * AP_DOMAINS + queue];
stat->hwtype = zc->card->ap_dev.device_type;
stat->functions = zc->card->functions >> 26;
stat->qid = zq->queue->qid;
stat->online = zq->online ? 0x01 : 0x00;
}
}
spin_unlock(&zcrypt_list_lock);
}
EXPORT_SYMBOL(zcrypt_device_status_mask_ext);
static void zcrypt_status_mask(char status[], size_t max_adapters)
{
struct zcrypt_card *zc;
struct zcrypt_queue *zq;
int card;
memset(status, 0, max_adapters);
spin_lock(&zcrypt_list_lock);
for_each_zcrypt_card(zc) {
for_each_zcrypt_queue(zq, zc) {
card = AP_QID_CARD(zq->queue->qid);
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
|| card >= max_adapters)
continue; continue;
status[AP_QID_CARD(zq->queue->qid)] = status[card] = zc->online ? zc->user_space_type : 0x0d;
zc->online ? zc->user_space_type : 0x0d;
} }
} }
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
} }
static void zcrypt_qdepth_mask(char qdepth[AP_DEVICES]) static void zcrypt_qdepth_mask(char qdepth[], size_t max_adapters)
{ {
struct zcrypt_card *zc; struct zcrypt_card *zc;
struct zcrypt_queue *zq; struct zcrypt_queue *zq;
int card;
memset(qdepth, 0, sizeof(char) * AP_DEVICES); memset(qdepth, 0, max_adapters);
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
local_bh_disable(); local_bh_disable();
for_each_zcrypt_card(zc) { for_each_zcrypt_card(zc) {
for_each_zcrypt_queue(zq, zc) { for_each_zcrypt_queue(zq, zc) {
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) card = AP_QID_CARD(zq->queue->qid);
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
|| card >= max_adapters)
continue; continue;
spin_lock(&zq->queue->lock); spin_lock(&zq->queue->lock);
qdepth[AP_QID_CARD(zq->queue->qid)] = qdepth[card] =
zq->queue->pendingq_count + zq->queue->pendingq_count +
zq->queue->requestq_count; zq->queue->requestq_count;
spin_unlock(&zq->queue->lock); spin_unlock(&zq->queue->lock);
...@@ -669,21 +704,23 @@ static void zcrypt_qdepth_mask(char qdepth[AP_DEVICES]) ...@@ -669,21 +704,23 @@ static void zcrypt_qdepth_mask(char qdepth[AP_DEVICES])
spin_unlock(&zcrypt_list_lock); spin_unlock(&zcrypt_list_lock);
} }
static void zcrypt_perdev_reqcnt(int reqcnt[AP_DEVICES]) static void zcrypt_perdev_reqcnt(int reqcnt[], size_t max_adapters)
{ {
struct zcrypt_card *zc; struct zcrypt_card *zc;
struct zcrypt_queue *zq; struct zcrypt_queue *zq;
int card;
memset(reqcnt, 0, sizeof(int) * AP_DEVICES); memset(reqcnt, 0, sizeof(int) * max_adapters);
spin_lock(&zcrypt_list_lock); spin_lock(&zcrypt_list_lock);
local_bh_disable(); local_bh_disable();
for_each_zcrypt_card(zc) { for_each_zcrypt_card(zc) {
for_each_zcrypt_queue(zq, zc) { for_each_zcrypt_queue(zq, zc) {
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index) card = AP_QID_CARD(zq->queue->qid);
if (AP_QID_QUEUE(zq->queue->qid) != ap_domain_index
|| card >= max_adapters)
continue; continue;
spin_lock(&zq->queue->lock); spin_lock(&zq->queue->lock);
reqcnt[AP_QID_CARD(zq->queue->qid)] = reqcnt[card] = zq->queue->total_request_count;
zq->queue->total_request_count;
spin_unlock(&zq->queue->lock); spin_unlock(&zq->queue->lock);
} }
} }
...@@ -740,7 +777,7 @@ static int zcrypt_requestq_count(void) ...@@ -740,7 +777,7 @@ static int zcrypt_requestq_count(void)
static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
int rc; int rc = 0;
switch (cmd) { switch (cmd) {
case ICARSAMODEXPO: { case ICARSAMODEXPO: {
...@@ -819,48 +856,48 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -819,48 +856,48 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
return -EFAULT; return -EFAULT;
return rc; return rc;
} }
case ZDEVICESTATUS: { case ZCRYPT_DEVICE_STATUS: {
struct zcrypt_device_matrix *device_status; struct zcrypt_device_status_ext *device_status;
size_t total_size = MAX_ZDEV_ENTRIES_EXT
* sizeof(struct zcrypt_device_status_ext);
device_status = kzalloc(sizeof(struct zcrypt_device_matrix), device_status = kzalloc(total_size, GFP_KERNEL);
GFP_KERNEL);
if (!device_status) if (!device_status)
return -ENOMEM; return -ENOMEM;
zcrypt_device_status_mask_ext(device_status);
zcrypt_device_status_mask(device_status);
if (copy_to_user((char __user *) arg, device_status, if (copy_to_user((char __user *) arg, device_status,
sizeof(struct zcrypt_device_matrix))) { total_size))
kfree(device_status); rc = -EFAULT;
return -EFAULT;
}
kfree(device_status); kfree(device_status);
return 0; return rc;
} }
case Z90STAT_STATUS_MASK: { case ZCRYPT_STATUS_MASK: {
char status[AP_DEVICES]; char status[AP_DEVICES];
zcrypt_status_mask(status);
if (copy_to_user((char __user *) arg, status, zcrypt_status_mask(status, AP_DEVICES);
sizeof(char) * AP_DEVICES)) if (copy_to_user((char __user *) arg, status, sizeof(status)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case Z90STAT_QDEPTH_MASK: { case ZCRYPT_QDEPTH_MASK: {
char qdepth[AP_DEVICES]; char qdepth[AP_DEVICES];
zcrypt_qdepth_mask(qdepth);
if (copy_to_user((char __user *) arg, qdepth, zcrypt_qdepth_mask(qdepth, AP_DEVICES);
sizeof(char) * AP_DEVICES)) if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case Z90STAT_PERDEV_REQCNT: { case ZCRYPT_PERDEV_REQCNT: {
int reqcnt[AP_DEVICES]; int *reqcnt;
zcrypt_perdev_reqcnt(reqcnt);
if (copy_to_user((int __user *) arg, reqcnt, reqcnt = kcalloc(AP_DEVICES, sizeof(int), GFP_KERNEL);
sizeof(int) * AP_DEVICES)) if (!reqcnt)
return -EFAULT; return -ENOMEM;
return 0; zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES);
if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt)))
rc = -EFAULT;
kfree(reqcnt);
return rc;
} }
case Z90STAT_REQUESTQ_COUNT: case Z90STAT_REQUESTQ_COUNT:
return put_user(zcrypt_requestq_count(), (int __user *) arg); return put_user(zcrypt_requestq_count(), (int __user *) arg);
...@@ -871,8 +908,55 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd, ...@@ -871,8 +908,55 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
(int __user *) arg); (int __user *) arg);
case Z90STAT_DOMAIN_INDEX: case Z90STAT_DOMAIN_INDEX:
return put_user(ap_domain_index, (int __user *) arg); return put_user(ap_domain_index, (int __user *) arg);
/*
* Deprecated ioctls
*/
case ZDEVICESTATUS: {
/* the old ioctl supports only 64 adapters */
struct zcrypt_device_status *device_status;
size_t total_size = MAX_ZDEV_ENTRIES
* sizeof(struct zcrypt_device_status);
device_status = kzalloc(total_size, GFP_KERNEL);
if (!device_status)
return -ENOMEM;
zcrypt_device_status_mask(device_status);
if (copy_to_user((char __user *) arg, device_status,
total_size))
rc = -EFAULT;
kfree(device_status);
return rc;
}
case Z90STAT_STATUS_MASK: {
/* the old ioctl supports only 64 adapters */
char status[MAX_ZDEV_CARDIDS];
zcrypt_status_mask(status, MAX_ZDEV_CARDIDS);
if (copy_to_user((char __user *) arg, status, sizeof(status)))
return -EFAULT;
return 0;
}
case Z90STAT_QDEPTH_MASK: {
/* the old ioctl supports only 64 adapters */
char qdepth[MAX_ZDEV_CARDIDS];
zcrypt_qdepth_mask(qdepth, MAX_ZDEV_CARDIDS);
if (copy_to_user((char __user *) arg, qdepth, sizeof(qdepth)))
return -EFAULT;
return 0;
}
case Z90STAT_PERDEV_REQCNT: {
/* the old ioctl supports only 64 adapters */
int reqcnt[MAX_ZDEV_CARDIDS];
zcrypt_perdev_reqcnt(reqcnt, MAX_ZDEV_CARDIDS);
if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt)))
return -EFAULT;
return 0;
}
/* unknown ioctl number */ /* unknown ioctl number */
default: default:
ZCRYPT_DBF(DBF_DEBUG, "unknown ioctl 0x%08x\n", cmd);
return -ENOIOCTLCMD; return -ENOIOCTLCMD;
} }
} }
......
...@@ -155,6 +155,6 @@ struct zcrypt_ops *zcrypt_msgtype(unsigned char *, int); ...@@ -155,6 +155,6 @@ struct zcrypt_ops *zcrypt_msgtype(unsigned char *, int);
int zcrypt_api_init(void); int zcrypt_api_init(void);
void zcrypt_api_exit(void); void zcrypt_api_exit(void);
long zcrypt_send_cprb(struct ica_xcRB *xcRB); long zcrypt_send_cprb(struct ica_xcRB *xcRB);
void zcrypt_device_status_mask(struct zcrypt_device_matrix *devstatus); void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus);
#endif /* _ZCRYPT_API_H_ */ #endif /* _ZCRYPT_API_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