1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright IBM Corp. 2012, 2019
4 * Author(s): Holger Dengler <hd@linux.vnet.ibm.com>
7 #include <linux/module.h>
8 #include <linux/slab.h>
9 #include <linux/init.h>
10 #include <linux/err.h>
11 #include <linux/atomic.h>
12 #include <linux/uaccess.h>
13 #include <linux/mod_devicetable.h>
16 #include "zcrypt_api.h"
17 #include "zcrypt_msgtype6.h"
18 #include "zcrypt_msgtype50.h"
19 #include "zcrypt_error.h"
20 #include "zcrypt_cex4.h"
21 #include "zcrypt_ccamisc.h"
22 #include "zcrypt_ep11misc.h"
24 #define CEX4A_MIN_MOD_SIZE 1 /* 8 bits */
25 #define CEX4A_MAX_MOD_SIZE_2K 256 /* 2048 bits */
26 #define CEX4A_MAX_MOD_SIZE_4K 512 /* 4096 bits */
28 #define CEX4C_MIN_MOD_SIZE 16 /* 256 bits */
29 #define CEX4C_MAX_MOD_SIZE 512 /* 4096 bits */
31 /* Waiting time for requests to be processed.
32 * Currently there are some types of request which are not deterministic.
33 * But the maximum time limit managed by the stomper code is set to 60sec.
34 * Hence we have to wait at least that time period.
36 #define CEX4_CLEANUP_TIME (900*HZ)
38 MODULE_AUTHOR("IBM Corporation");
39 MODULE_DESCRIPTION("CEX4/CEX5/CEX6/CEX7 Cryptographic Card device driver, " \
40 "Copyright IBM Corp. 2019");
41 MODULE_LICENSE("GPL");
43 static struct ap_device_id zcrypt_cex4_card_ids[] = {
44 { .dev_type = AP_DEVICE_TYPE_CEX4,
45 .match_flags = AP_DEVICE_ID_MATCH_CARD_TYPE },
46 { .dev_type = AP_DEVICE_TYPE_CEX5,
47 .match_flags = AP_DEVICE_ID_MATCH_CARD_TYPE },
48 { .dev_type = AP_DEVICE_TYPE_CEX6,
49 .match_flags = AP_DEVICE_ID_MATCH_CARD_TYPE },
50 { .dev_type = AP_DEVICE_TYPE_CEX7,
51 .match_flags = AP_DEVICE_ID_MATCH_CARD_TYPE },
52 { /* end of list */ },
55 MODULE_DEVICE_TABLE(ap, zcrypt_cex4_card_ids);
57 static struct ap_device_id zcrypt_cex4_queue_ids[] = {
58 { .dev_type = AP_DEVICE_TYPE_CEX4,
59 .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE },
60 { .dev_type = AP_DEVICE_TYPE_CEX5,
61 .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE },
62 { .dev_type = AP_DEVICE_TYPE_CEX6,
63 .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE },
64 { .dev_type = AP_DEVICE_TYPE_CEX7,
65 .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE },
66 { /* end of list */ },
69 MODULE_DEVICE_TABLE(ap, zcrypt_cex4_queue_ids);
72 * CCA card additional device attributes
74 static ssize_t cca_serialnr_show(struct device *dev,
75 struct device_attribute *attr,
79 struct ap_card *ac = to_ap_card(dev);
80 struct zcrypt_card *zc = ac->private;
82 memset(&ci, 0, sizeof(ci));
84 if (ap_domain_index >= 0)
85 cca_get_info(ac->id, ap_domain_index, &ci, zc->online);
87 return scnprintf(buf, PAGE_SIZE, "%s\n", ci.serial);
90 static struct device_attribute dev_attr_cca_serialnr =
91 __ATTR(serialnr, 0444, cca_serialnr_show, NULL);
93 static struct attribute *cca_card_attrs[] = {
94 &dev_attr_cca_serialnr.attr,
98 static const struct attribute_group cca_card_attr_grp = {
99 .attrs = cca_card_attrs,
103 * CCA queue additional device attributes
105 static ssize_t cca_mkvps_show(struct device *dev,
106 struct device_attribute *attr,
111 struct zcrypt_queue *zq = to_ap_queue(dev)->private;
112 static const char * const cao_state[] = { "invalid", "valid" };
113 static const char * const new_state[] = { "empty", "partial", "full" };
115 memset(&ci, 0, sizeof(ci));
117 cca_get_info(AP_QID_CARD(zq->queue->qid),
118 AP_QID_QUEUE(zq->queue->qid),
121 if (ci.new_aes_mk_state >= '1' && ci.new_aes_mk_state <= '3')
122 n = scnprintf(buf, PAGE_SIZE, "AES NEW: %s 0x%016llx\n",
123 new_state[ci.new_aes_mk_state - '1'],
126 n = scnprintf(buf, PAGE_SIZE, "AES NEW: - -\n");
128 if (ci.cur_aes_mk_state >= '1' && ci.cur_aes_mk_state <= '2')
129 n += scnprintf(buf + n, PAGE_SIZE - n,
130 "AES CUR: %s 0x%016llx\n",
131 cao_state[ci.cur_aes_mk_state - '1'],
134 n += scnprintf(buf + n, PAGE_SIZE - n, "AES CUR: - -\n");
136 if (ci.old_aes_mk_state >= '1' && ci.old_aes_mk_state <= '2')
137 n += scnprintf(buf + n, PAGE_SIZE - n,
138 "AES OLD: %s 0x%016llx\n",
139 cao_state[ci.old_aes_mk_state - '1'],
142 n += scnprintf(buf + n, PAGE_SIZE - n, "AES OLD: - -\n");
144 if (ci.new_apka_mk_state >= '1' && ci.new_apka_mk_state <= '3')
145 n += scnprintf(buf + n, PAGE_SIZE - n,
146 "APKA NEW: %s 0x%016llx\n",
147 new_state[ci.new_apka_mk_state - '1'],
150 n += scnprintf(buf + n, PAGE_SIZE - n, "APKA NEW: - -\n");
152 if (ci.cur_apka_mk_state >= '1' && ci.cur_apka_mk_state <= '2')
153 n += scnprintf(buf + n, PAGE_SIZE - n,
154 "APKA CUR: %s 0x%016llx\n",
155 cao_state[ci.cur_apka_mk_state - '1'],
158 n += scnprintf(buf + n, PAGE_SIZE - n, "APKA CUR: - -\n");
160 if (ci.old_apka_mk_state >= '1' && ci.old_apka_mk_state <= '2')
161 n += scnprintf(buf + n, PAGE_SIZE - n,
162 "APKA OLD: %s 0x%016llx\n",
163 cao_state[ci.old_apka_mk_state - '1'],
166 n += scnprintf(buf + n, PAGE_SIZE - n, "APKA OLD: - -\n");
171 static struct device_attribute dev_attr_cca_mkvps =
172 __ATTR(mkvps, 0444, cca_mkvps_show, NULL);
174 static struct attribute *cca_queue_attrs[] = {
175 &dev_attr_cca_mkvps.attr,
179 static const struct attribute_group cca_queue_attr_grp = {
180 .attrs = cca_queue_attrs,
184 * EP11 card additional device attributes
186 static ssize_t ep11_api_ordinalnr_show(struct device *dev,
187 struct device_attribute *attr,
190 struct ep11_card_info ci;
191 struct ap_card *ac = to_ap_card(dev);
192 struct zcrypt_card *zc = ac->private;
194 memset(&ci, 0, sizeof(ci));
196 ep11_get_card_info(ac->id, &ci, zc->online);
198 if (ci.API_ord_nr > 0)
199 return scnprintf(buf, PAGE_SIZE, "%u\n", ci.API_ord_nr);
201 return scnprintf(buf, PAGE_SIZE, "\n");
204 static struct device_attribute dev_attr_ep11_api_ordinalnr =
205 __ATTR(API_ordinalnr, 0444, ep11_api_ordinalnr_show, NULL);
207 static ssize_t ep11_fw_version_show(struct device *dev,
208 struct device_attribute *attr,
211 struct ep11_card_info ci;
212 struct ap_card *ac = to_ap_card(dev);
213 struct zcrypt_card *zc = ac->private;
215 memset(&ci, 0, sizeof(ci));
217 ep11_get_card_info(ac->id, &ci, zc->online);
219 if (ci.FW_version > 0)
220 return scnprintf(buf, PAGE_SIZE, "%d.%d\n",
221 (int)(ci.FW_version >> 8),
222 (int)(ci.FW_version & 0xFF));
224 return scnprintf(buf, PAGE_SIZE, "\n");
227 static struct device_attribute dev_attr_ep11_fw_version =
228 __ATTR(FW_version, 0444, ep11_fw_version_show, NULL);
230 static ssize_t ep11_serialnr_show(struct device *dev,
231 struct device_attribute *attr,
234 struct ep11_card_info ci;
235 struct ap_card *ac = to_ap_card(dev);
236 struct zcrypt_card *zc = ac->private;
238 memset(&ci, 0, sizeof(ci));
240 ep11_get_card_info(ac->id, &ci, zc->online);
243 return scnprintf(buf, PAGE_SIZE, "%16.16s\n", ci.serial);
245 return scnprintf(buf, PAGE_SIZE, "\n");
248 static struct device_attribute dev_attr_ep11_serialnr =
249 __ATTR(serialnr, 0444, ep11_serialnr_show, NULL);
251 static const struct {
253 const char *mode_txt;
254 } ep11_op_modes[] = {
263 static ssize_t ep11_card_op_modes_show(struct device *dev,
264 struct device_attribute *attr,
268 struct ep11_card_info ci;
269 struct ap_card *ac = to_ap_card(dev);
270 struct zcrypt_card *zc = ac->private;
272 memset(&ci, 0, sizeof(ci));
274 ep11_get_card_info(ac->id, &ci, zc->online);
276 for (i = 0; ep11_op_modes[i].mode_txt; i++) {
277 if (ci.op_mode & (1ULL << ep11_op_modes[i].mode_bit)) {
280 n += scnprintf(buf + n, PAGE_SIZE - n,
281 "%s", ep11_op_modes[i].mode_txt);
284 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
289 static struct device_attribute dev_attr_ep11_card_op_modes =
290 __ATTR(op_modes, 0444, ep11_card_op_modes_show, NULL);
292 static struct attribute *ep11_card_attrs[] = {
293 &dev_attr_ep11_api_ordinalnr.attr,
294 &dev_attr_ep11_fw_version.attr,
295 &dev_attr_ep11_serialnr.attr,
296 &dev_attr_ep11_card_op_modes.attr,
300 static const struct attribute_group ep11_card_attr_grp = {
301 .attrs = ep11_card_attrs,
305 * EP11 queue additional device attributes
308 static ssize_t ep11_mkvps_show(struct device *dev,
309 struct device_attribute *attr,
313 struct ep11_domain_info di;
314 struct zcrypt_queue *zq = to_ap_queue(dev)->private;
315 static const char * const cwk_state[] = { "invalid", "valid" };
316 static const char * const nwk_state[] = { "empty", "uncommitted",
319 memset(&di, 0, sizeof(di));
322 ep11_get_domain_info(AP_QID_CARD(zq->queue->qid),
323 AP_QID_QUEUE(zq->queue->qid),
326 if (di.cur_wk_state == '0') {
327 n = scnprintf(buf, PAGE_SIZE, "WK CUR: %s -\n",
328 cwk_state[di.cur_wk_state - '0']);
329 } else if (di.cur_wk_state == '1') {
330 n = scnprintf(buf, PAGE_SIZE, "WK CUR: %s 0x",
331 cwk_state[di.cur_wk_state - '0']);
332 bin2hex(buf + n, di.cur_wkvp, sizeof(di.cur_wkvp));
333 n += 2 * sizeof(di.cur_wkvp);
334 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
336 n = scnprintf(buf, PAGE_SIZE, "WK CUR: - -\n");
338 if (di.new_wk_state == '0') {
339 n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: %s -\n",
340 nwk_state[di.new_wk_state - '0']);
341 } else if (di.new_wk_state >= '1' && di.new_wk_state <= '2') {
342 n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: %s 0x",
343 nwk_state[di.new_wk_state - '0']);
344 bin2hex(buf + n, di.new_wkvp, sizeof(di.new_wkvp));
345 n += 2 * sizeof(di.new_wkvp);
346 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
348 n += scnprintf(buf + n, PAGE_SIZE - n, "WK NEW: - -\n");
353 static struct device_attribute dev_attr_ep11_mkvps =
354 __ATTR(mkvps, 0444, ep11_mkvps_show, NULL);
356 static ssize_t ep11_queue_op_modes_show(struct device *dev,
357 struct device_attribute *attr,
361 struct ep11_domain_info di;
362 struct zcrypt_queue *zq = to_ap_queue(dev)->private;
364 memset(&di, 0, sizeof(di));
367 ep11_get_domain_info(AP_QID_CARD(zq->queue->qid),
368 AP_QID_QUEUE(zq->queue->qid),
371 for (i = 0; ep11_op_modes[i].mode_txt; i++) {
372 if (di.op_mode & (1ULL << ep11_op_modes[i].mode_bit)) {
375 n += scnprintf(buf + n, PAGE_SIZE - n,
376 "%s", ep11_op_modes[i].mode_txt);
379 n += scnprintf(buf + n, PAGE_SIZE - n, "\n");
384 static struct device_attribute dev_attr_ep11_queue_op_modes =
385 __ATTR(op_modes, 0444, ep11_queue_op_modes_show, NULL);
387 static struct attribute *ep11_queue_attrs[] = {
388 &dev_attr_ep11_mkvps.attr,
389 &dev_attr_ep11_queue_op_modes.attr,
393 static const struct attribute_group ep11_queue_attr_grp = {
394 .attrs = ep11_queue_attrs,
398 * Probe function for CEX4/CEX5/CEX6/CEX7 card device. It always
399 * accepts the AP device since the bus_match already checked
401 * @ap_dev: pointer to the AP device.
403 static int zcrypt_cex4_card_probe(struct ap_device *ap_dev)
406 * Normalized speed ratings per crypto adapter
407 * MEX_1k, MEX_2k, MEX_4k, CRT_1k, CRT_2k, CRT_4k, RNG, SECKEY
409 static const int CEX4A_SPEED_IDX[NUM_OPS] = {
410 14, 19, 249, 42, 228, 1458, 0, 0};
411 static const int CEX5A_SPEED_IDX[NUM_OPS] = {
412 8, 9, 20, 18, 66, 458, 0, 0};
413 static const int CEX6A_SPEED_IDX[NUM_OPS] = {
414 6, 9, 20, 17, 65, 438, 0, 0};
415 static const int CEX7A_SPEED_IDX[NUM_OPS] = {
416 6, 8, 17, 15, 54, 362, 0, 0};
418 static const int CEX4C_SPEED_IDX[NUM_OPS] = {
419 59, 69, 308, 83, 278, 2204, 209, 40};
420 static const int CEX5C_SPEED_IDX[] = {
421 24, 31, 50, 37, 90, 479, 27, 10};
422 static const int CEX6C_SPEED_IDX[NUM_OPS] = {
423 16, 20, 32, 27, 77, 455, 24, 9};
424 static const int CEX7C_SPEED_IDX[NUM_OPS] = {
425 14, 16, 26, 23, 64, 376, 23, 8};
427 static const int CEX4P_SPEED_IDX[NUM_OPS] = {
428 0, 0, 0, 0, 0, 0, 0, 50};
429 static const int CEX5P_SPEED_IDX[NUM_OPS] = {
430 0, 0, 0, 0, 0, 0, 0, 10};
431 static const int CEX6P_SPEED_IDX[NUM_OPS] = {
432 0, 0, 0, 0, 0, 0, 0, 9};
433 static const int CEX7P_SPEED_IDX[NUM_OPS] = {
434 0, 0, 0, 0, 0, 0, 0, 8};
436 struct ap_card *ac = to_ap_card(&ap_dev->device);
437 struct zcrypt_card *zc;
440 zc = zcrypt_card_alloc();
445 if (ap_test_bit(&ac->functions, AP_FUNC_ACCEL)) {
446 if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX4) {
447 zc->type_string = "CEX4A";
448 zc->user_space_type = ZCRYPT_CEX4;
449 zc->speed_rating = CEX4A_SPEED_IDX;
450 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX5) {
451 zc->type_string = "CEX5A";
452 zc->user_space_type = ZCRYPT_CEX5;
453 zc->speed_rating = CEX5A_SPEED_IDX;
454 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX6) {
455 zc->type_string = "CEX6A";
456 zc->user_space_type = ZCRYPT_CEX6;
457 zc->speed_rating = CEX6A_SPEED_IDX;
459 zc->type_string = "CEX7A";
460 /* wrong user space type, just for compatibility
461 * with the ZCRYPT_STATUS_MASK ioctl.
463 zc->user_space_type = ZCRYPT_CEX6;
464 zc->speed_rating = CEX7A_SPEED_IDX;
466 zc->min_mod_size = CEX4A_MIN_MOD_SIZE;
467 if (ap_test_bit(&ac->functions, AP_FUNC_MEX4K) &&
468 ap_test_bit(&ac->functions, AP_FUNC_CRT4K)) {
469 zc->max_mod_size = CEX4A_MAX_MOD_SIZE_4K;
470 zc->max_exp_bit_length =
471 CEX4A_MAX_MOD_SIZE_4K;
473 zc->max_mod_size = CEX4A_MAX_MOD_SIZE_2K;
474 zc->max_exp_bit_length =
475 CEX4A_MAX_MOD_SIZE_2K;
477 } else if (ap_test_bit(&ac->functions, AP_FUNC_COPRO)) {
478 if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX4) {
479 zc->type_string = "CEX4C";
480 /* wrong user space type, must be CEX4
481 * just keep it for cca compatibility
483 zc->user_space_type = ZCRYPT_CEX3C;
484 zc->speed_rating = CEX4C_SPEED_IDX;
485 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX5) {
486 zc->type_string = "CEX5C";
487 /* wrong user space type, must be CEX5
488 * just keep it for cca compatibility
490 zc->user_space_type = ZCRYPT_CEX3C;
491 zc->speed_rating = CEX5C_SPEED_IDX;
492 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX6) {
493 zc->type_string = "CEX6C";
494 /* wrong user space type, must be CEX6
495 * just keep it for cca compatibility
497 zc->user_space_type = ZCRYPT_CEX3C;
498 zc->speed_rating = CEX6C_SPEED_IDX;
500 zc->type_string = "CEX7C";
501 /* wrong user space type, must be CEX7
502 * just keep it for cca compatibility
504 zc->user_space_type = ZCRYPT_CEX3C;
505 zc->speed_rating = CEX7C_SPEED_IDX;
507 zc->min_mod_size = CEX4C_MIN_MOD_SIZE;
508 zc->max_mod_size = CEX4C_MAX_MOD_SIZE;
509 zc->max_exp_bit_length = CEX4C_MAX_MOD_SIZE;
510 } else if (ap_test_bit(&ac->functions, AP_FUNC_EP11)) {
511 if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX4) {
512 zc->type_string = "CEX4P";
513 zc->user_space_type = ZCRYPT_CEX4;
514 zc->speed_rating = CEX4P_SPEED_IDX;
515 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX5) {
516 zc->type_string = "CEX5P";
517 zc->user_space_type = ZCRYPT_CEX5;
518 zc->speed_rating = CEX5P_SPEED_IDX;
519 } else if (ac->ap_dev.device_type == AP_DEVICE_TYPE_CEX6) {
520 zc->type_string = "CEX6P";
521 zc->user_space_type = ZCRYPT_CEX6;
522 zc->speed_rating = CEX6P_SPEED_IDX;
524 zc->type_string = "CEX7P";
525 /* wrong user space type, just for compatibility
526 * with the ZCRYPT_STATUS_MASK ioctl.
528 zc->user_space_type = ZCRYPT_CEX6;
529 zc->speed_rating = CEX7P_SPEED_IDX;
531 zc->min_mod_size = CEX4C_MIN_MOD_SIZE;
532 zc->max_mod_size = CEX4C_MAX_MOD_SIZE;
533 zc->max_exp_bit_length = CEX4C_MAX_MOD_SIZE;
535 zcrypt_card_free(zc);
540 rc = zcrypt_card_register(zc);
543 zcrypt_card_free(zc);
547 if (ap_test_bit(&ac->functions, AP_FUNC_COPRO)) {
548 rc = sysfs_create_group(&ap_dev->device.kobj,
551 zcrypt_card_unregister(zc);
553 zcrypt_card_free(zc);
555 } else if (ap_test_bit(&ac->functions, AP_FUNC_EP11)) {
556 rc = sysfs_create_group(&ap_dev->device.kobj,
557 &ep11_card_attr_grp);
559 zcrypt_card_unregister(zc);
561 zcrypt_card_free(zc);
569 * This is called to remove the CEX4/CEX5/CEX6/CEX7 card driver
570 * information if an AP card device is removed.
572 static void zcrypt_cex4_card_remove(struct ap_device *ap_dev)
574 struct ap_card *ac = to_ap_card(&ap_dev->device);
575 struct zcrypt_card *zc = ac->private;
577 if (ap_test_bit(&ac->functions, AP_FUNC_COPRO))
578 sysfs_remove_group(&ap_dev->device.kobj, &cca_card_attr_grp);
579 else if (ap_test_bit(&ac->functions, AP_FUNC_EP11))
580 sysfs_remove_group(&ap_dev->device.kobj, &ep11_card_attr_grp);
582 zcrypt_card_unregister(zc);
585 static struct ap_driver zcrypt_cex4_card_driver = {
586 .probe = zcrypt_cex4_card_probe,
587 .remove = zcrypt_cex4_card_remove,
588 .ids = zcrypt_cex4_card_ids,
589 .flags = AP_DRIVER_FLAG_DEFAULT,
593 * Probe function for CEX4/CEX5/CEX6/CEX7 queue device. It always
594 * accepts the AP device since the bus_match already checked
596 * @ap_dev: pointer to the AP device.
598 static int zcrypt_cex4_queue_probe(struct ap_device *ap_dev)
600 struct ap_queue *aq = to_ap_queue(&ap_dev->device);
601 struct zcrypt_queue *zq;
604 if (ap_test_bit(&aq->card->functions, AP_FUNC_ACCEL)) {
605 zq = zcrypt_queue_alloc(aq->card->maxmsgsize);
608 zq->ops = zcrypt_msgtype(MSGTYPE50_NAME,
609 MSGTYPE50_VARIANT_DEFAULT);
610 } else if (ap_test_bit(&aq->card->functions, AP_FUNC_COPRO)) {
611 zq = zcrypt_queue_alloc(aq->card->maxmsgsize);
614 zq->ops = zcrypt_msgtype(MSGTYPE06_NAME,
615 MSGTYPE06_VARIANT_DEFAULT);
616 } else if (ap_test_bit(&aq->card->functions, AP_FUNC_EP11)) {
617 zq = zcrypt_queue_alloc(aq->card->maxmsgsize);
620 zq->ops = zcrypt_msgtype(MSGTYPE06_NAME,
621 MSGTYPE06_VARIANT_EP11);
628 atomic_set(&zq->load, 0);
629 ap_queue_init_state(aq);
630 ap_queue_init_reply(aq, &zq->reply);
631 aq->request_timeout = CEX4_CLEANUP_TIME;
633 rc = zcrypt_queue_register(zq);
636 zcrypt_queue_free(zq);
640 if (ap_test_bit(&aq->card->functions, AP_FUNC_COPRO)) {
641 rc = sysfs_create_group(&ap_dev->device.kobj,
642 &cca_queue_attr_grp);
644 zcrypt_queue_unregister(zq);
646 zcrypt_queue_free(zq);
648 } else if (ap_test_bit(&aq->card->functions, AP_FUNC_EP11)) {
649 rc = sysfs_create_group(&ap_dev->device.kobj,
650 &ep11_queue_attr_grp);
652 zcrypt_queue_unregister(zq);
654 zcrypt_queue_free(zq);
662 * This is called to remove the CEX4/CEX5/CEX6/CEX7 queue driver
663 * information if an AP queue device is removed.
665 static void zcrypt_cex4_queue_remove(struct ap_device *ap_dev)
667 struct ap_queue *aq = to_ap_queue(&ap_dev->device);
668 struct zcrypt_queue *zq = aq->private;
670 if (ap_test_bit(&aq->card->functions, AP_FUNC_COPRO))
671 sysfs_remove_group(&ap_dev->device.kobj, &cca_queue_attr_grp);
672 else if (ap_test_bit(&aq->card->functions, AP_FUNC_EP11))
673 sysfs_remove_group(&ap_dev->device.kobj, &ep11_queue_attr_grp);
675 zcrypt_queue_unregister(zq);
678 static struct ap_driver zcrypt_cex4_queue_driver = {
679 .probe = zcrypt_cex4_queue_probe,
680 .remove = zcrypt_cex4_queue_remove,
681 .ids = zcrypt_cex4_queue_ids,
682 .flags = AP_DRIVER_FLAG_DEFAULT,
685 int __init zcrypt_cex4_init(void)
689 rc = ap_driver_register(&zcrypt_cex4_card_driver,
690 THIS_MODULE, "cex4card");
694 rc = ap_driver_register(&zcrypt_cex4_queue_driver,
695 THIS_MODULE, "cex4queue");
697 ap_driver_unregister(&zcrypt_cex4_card_driver);
702 void __exit zcrypt_cex4_exit(void)
704 ap_driver_unregister(&zcrypt_cex4_queue_driver);
705 ap_driver_unregister(&zcrypt_cex4_card_driver);
708 module_init(zcrypt_cex4_init);
709 module_exit(zcrypt_cex4_exit);