• Home
  • Raw
  • Download

Lines Matching refs:zdev

86 	struct zcrypt_device *zdev = to_ap_dev(dev)->private;  in zcrypt_type_show()  local
87 return snprintf(buf, PAGE_SIZE, "%s\n", zdev->type_string); in zcrypt_type_show()
95 struct zcrypt_device *zdev = to_ap_dev(dev)->private; in zcrypt_online_show() local
96 return snprintf(buf, PAGE_SIZE, "%d\n", zdev->online); in zcrypt_online_show()
103 struct zcrypt_device *zdev = to_ap_dev(dev)->private; in zcrypt_online_store() local
108 zdev->online = online; in zcrypt_online_store()
109 ZCRYPT_DBF_DEV(DBF_INFO, zdev, "dev%04xo%dman", zdev->ap_dev->qid, in zcrypt_online_store()
110 zdev->online); in zcrypt_online_store()
112 ap_flush_queue(zdev->ap_dev); in zcrypt_online_store()
154 static void __zcrypt_increase_preference(struct zcrypt_device *zdev) in __zcrypt_increase_preference() argument
159 if (zdev->speed_rating == 0) in __zcrypt_increase_preference()
161 for (l = zdev->list.prev; l != &zcrypt_device_list; l = l->prev) { in __zcrypt_increase_preference()
164 (zdev->request_count + 1) * zdev->speed_rating && in __zcrypt_increase_preference()
168 if (l == zdev->list.prev) in __zcrypt_increase_preference()
171 list_move(&zdev->list, l); in __zcrypt_increase_preference()
182 static void __zcrypt_decrease_preference(struct zcrypt_device *zdev) in __zcrypt_decrease_preference() argument
187 if (zdev->speed_rating == 0) in __zcrypt_decrease_preference()
189 for (l = zdev->list.next; l != &zcrypt_device_list; l = l->next) { in __zcrypt_decrease_preference()
192 (zdev->request_count + 1) * zdev->speed_rating || in __zcrypt_decrease_preference()
196 if (l == zdev->list.next) in __zcrypt_decrease_preference()
199 list_move_tail(&zdev->list, l); in __zcrypt_decrease_preference()
204 struct zcrypt_device *zdev = in zcrypt_device_release() local
206 zcrypt_device_free(zdev); in zcrypt_device_release()
209 void zcrypt_device_get(struct zcrypt_device *zdev) in zcrypt_device_get() argument
211 kref_get(&zdev->refcount); in zcrypt_device_get()
215 int zcrypt_device_put(struct zcrypt_device *zdev) in zcrypt_device_put() argument
217 return kref_put(&zdev->refcount, zcrypt_device_release); in zcrypt_device_put()
223 struct zcrypt_device *zdev; in zcrypt_device_alloc() local
225 zdev = kzalloc(sizeof(struct zcrypt_device), GFP_KERNEL); in zcrypt_device_alloc()
226 if (!zdev) in zcrypt_device_alloc()
228 zdev->reply.message = kmalloc(max_response_size, GFP_KERNEL); in zcrypt_device_alloc()
229 if (!zdev->reply.message) in zcrypt_device_alloc()
231 zdev->reply.length = max_response_size; in zcrypt_device_alloc()
232 spin_lock_init(&zdev->lock); in zcrypt_device_alloc()
233 INIT_LIST_HEAD(&zdev->list); in zcrypt_device_alloc()
234 zdev->dbf_area = zcrypt_dbf_devices; in zcrypt_device_alloc()
235 return zdev; in zcrypt_device_alloc()
238 kfree(zdev); in zcrypt_device_alloc()
243 void zcrypt_device_free(struct zcrypt_device *zdev) in zcrypt_device_free() argument
245 kfree(zdev->reply.message); in zcrypt_device_free()
246 kfree(zdev); in zcrypt_device_free()
256 int zcrypt_device_register(struct zcrypt_device *zdev) in zcrypt_device_register() argument
260 if (!zdev->ops) in zcrypt_device_register()
262 rc = sysfs_create_group(&zdev->ap_dev->device.kobj, in zcrypt_device_register()
266 get_device(&zdev->ap_dev->device); in zcrypt_device_register()
267 kref_init(&zdev->refcount); in zcrypt_device_register()
269 zdev->online = 1; /* New devices are online by default. */ in zcrypt_device_register()
270 ZCRYPT_DBF_DEV(DBF_INFO, zdev, "dev%04xo%dreg", zdev->ap_dev->qid, in zcrypt_device_register()
271 zdev->online); in zcrypt_device_register()
272 list_add_tail(&zdev->list, &zcrypt_device_list); in zcrypt_device_register()
273 __zcrypt_increase_preference(zdev); in zcrypt_device_register()
276 if (zdev->ops->rng) { in zcrypt_device_register()
286 list_del_init(&zdev->list); in zcrypt_device_register()
288 sysfs_remove_group(&zdev->ap_dev->device.kobj, in zcrypt_device_register()
290 put_device(&zdev->ap_dev->device); in zcrypt_device_register()
291 zcrypt_device_put(zdev); in zcrypt_device_register()
303 void zcrypt_device_unregister(struct zcrypt_device *zdev) in zcrypt_device_unregister() argument
305 if (zdev->ops->rng) in zcrypt_device_unregister()
309 list_del_init(&zdev->list); in zcrypt_device_unregister()
311 sysfs_remove_group(&zdev->ap_dev->device.kobj, in zcrypt_device_unregister()
313 put_device(&zdev->ap_dev->device); in zcrypt_device_unregister()
314 zcrypt_device_put(zdev); in zcrypt_device_unregister()
425 struct zcrypt_device *zdev; in zcrypt_rsa_modexpo() local
438 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_rsa_modexpo()
439 if (!zdev->online || in zcrypt_rsa_modexpo()
440 !zdev->ops->rsa_modexpo || in zcrypt_rsa_modexpo()
441 zdev->min_mod_size > mex->inputdatalength || in zcrypt_rsa_modexpo()
442 zdev->max_mod_size < mex->inputdatalength) in zcrypt_rsa_modexpo()
444 zcrypt_device_get(zdev); in zcrypt_rsa_modexpo()
445 get_device(&zdev->ap_dev->device); in zcrypt_rsa_modexpo()
446 zdev->request_count++; in zcrypt_rsa_modexpo()
447 __zcrypt_decrease_preference(zdev); in zcrypt_rsa_modexpo()
448 if (try_module_get(zdev->ap_dev->drv->driver.owner)) { in zcrypt_rsa_modexpo()
450 rc = zdev->ops->rsa_modexpo(zdev, mex); in zcrypt_rsa_modexpo()
452 module_put(zdev->ap_dev->drv->driver.owner); in zcrypt_rsa_modexpo()
456 zdev->request_count--; in zcrypt_rsa_modexpo()
457 __zcrypt_increase_preference(zdev); in zcrypt_rsa_modexpo()
458 put_device(&zdev->ap_dev->device); in zcrypt_rsa_modexpo()
459 zcrypt_device_put(zdev); in zcrypt_rsa_modexpo()
469 struct zcrypt_device *zdev; in zcrypt_rsa_crt() local
485 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_rsa_crt()
486 if (!zdev->online || in zcrypt_rsa_crt()
487 !zdev->ops->rsa_modexpo_crt || in zcrypt_rsa_crt()
488 zdev->min_mod_size > crt->inputdatalength || in zcrypt_rsa_crt()
489 zdev->max_mod_size < crt->inputdatalength) in zcrypt_rsa_crt()
491 if (zdev->short_crt && crt->inputdatalength > 240) { in zcrypt_rsa_crt()
528 zcrypt_device_get(zdev); in zcrypt_rsa_crt()
529 get_device(&zdev->ap_dev->device); in zcrypt_rsa_crt()
530 zdev->request_count++; in zcrypt_rsa_crt()
531 __zcrypt_decrease_preference(zdev); in zcrypt_rsa_crt()
532 if (try_module_get(zdev->ap_dev->drv->driver.owner)) { in zcrypt_rsa_crt()
534 rc = zdev->ops->rsa_modexpo_crt(zdev, crt); in zcrypt_rsa_crt()
536 module_put(zdev->ap_dev->drv->driver.owner); in zcrypt_rsa_crt()
540 zdev->request_count--; in zcrypt_rsa_crt()
541 __zcrypt_increase_preference(zdev); in zcrypt_rsa_crt()
542 put_device(&zdev->ap_dev->device); in zcrypt_rsa_crt()
543 zcrypt_device_put(zdev); in zcrypt_rsa_crt()
553 struct zcrypt_device *zdev; in zcrypt_send_cprb() local
557 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_send_cprb()
558 if (!zdev->online || !zdev->ops->send_cprb || in zcrypt_send_cprb()
559 (zdev->ops->variant == MSGTYPE06_VARIANT_EP11) || in zcrypt_send_cprb()
561 AP_QID_DEVICE(zdev->ap_dev->qid) != xcRB->user_defined)) in zcrypt_send_cprb()
563 zcrypt_device_get(zdev); in zcrypt_send_cprb()
564 get_device(&zdev->ap_dev->device); in zcrypt_send_cprb()
565 zdev->request_count++; in zcrypt_send_cprb()
566 __zcrypt_decrease_preference(zdev); in zcrypt_send_cprb()
567 if (try_module_get(zdev->ap_dev->drv->driver.owner)) { in zcrypt_send_cprb()
569 rc = zdev->ops->send_cprb(zdev, xcRB); in zcrypt_send_cprb()
571 module_put(zdev->ap_dev->drv->driver.owner); in zcrypt_send_cprb()
575 zdev->request_count--; in zcrypt_send_cprb()
576 __zcrypt_increase_preference(zdev); in zcrypt_send_cprb()
577 put_device(&zdev->ap_dev->device); in zcrypt_send_cprb()
578 zcrypt_device_put(zdev); in zcrypt_send_cprb()
607 struct zcrypt_device *zdev; in zcrypt_send_ep11_cprb() local
636 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_send_ep11_cprb()
638 if (!zdev->online || in zcrypt_send_ep11_cprb()
639 zdev->ops->variant != MSGTYPE06_VARIANT_EP11) in zcrypt_send_ep11_cprb()
643 if (!is_desired_ep11dev(zdev->ap_dev->qid, ep11_dev_list) && in zcrypt_send_ep11_cprb()
647 zcrypt_device_get(zdev); in zcrypt_send_ep11_cprb()
648 get_device(&zdev->ap_dev->device); in zcrypt_send_ep11_cprb()
649 zdev->request_count++; in zcrypt_send_ep11_cprb()
650 __zcrypt_decrease_preference(zdev); in zcrypt_send_ep11_cprb()
651 if (try_module_get(zdev->ap_dev->drv->driver.owner)) { in zcrypt_send_ep11_cprb()
653 rc = zdev->ops->send_ep11_cprb(zdev, xcrb); in zcrypt_send_ep11_cprb()
655 module_put(zdev->ap_dev->drv->driver.owner); in zcrypt_send_ep11_cprb()
659 zdev->request_count--; in zcrypt_send_ep11_cprb()
660 __zcrypt_increase_preference(zdev); in zcrypt_send_ep11_cprb()
661 put_device(&zdev->ap_dev->device); in zcrypt_send_ep11_cprb()
662 zcrypt_device_put(zdev); in zcrypt_send_ep11_cprb()
672 struct zcrypt_device *zdev; in zcrypt_rng() local
676 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_rng()
677 if (!zdev->online || !zdev->ops->rng) in zcrypt_rng()
679 zcrypt_device_get(zdev); in zcrypt_rng()
680 get_device(&zdev->ap_dev->device); in zcrypt_rng()
681 zdev->request_count++; in zcrypt_rng()
682 __zcrypt_decrease_preference(zdev); in zcrypt_rng()
683 if (try_module_get(zdev->ap_dev->drv->driver.owner)) { in zcrypt_rng()
685 rc = zdev->ops->rng(zdev, buffer); in zcrypt_rng()
687 module_put(zdev->ap_dev->drv->driver.owner); in zcrypt_rng()
690 zdev->request_count--; in zcrypt_rng()
691 __zcrypt_increase_preference(zdev); in zcrypt_rng()
692 put_device(&zdev->ap_dev->device); in zcrypt_rng()
693 zcrypt_device_put(zdev); in zcrypt_rng()
703 struct zcrypt_device *zdev; in zcrypt_status_mask() local
707 list_for_each_entry(zdev, &zcrypt_device_list, list) in zcrypt_status_mask()
708 status[AP_QID_DEVICE(zdev->ap_dev->qid)] = in zcrypt_status_mask()
709 zdev->online ? zdev->user_space_type : 0x0d; in zcrypt_status_mask()
715 struct zcrypt_device *zdev; in zcrypt_qdepth_mask() local
719 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_qdepth_mask()
720 spin_lock(&zdev->ap_dev->lock); in zcrypt_qdepth_mask()
721 qdepth[AP_QID_DEVICE(zdev->ap_dev->qid)] = in zcrypt_qdepth_mask()
722 zdev->ap_dev->pendingq_count + in zcrypt_qdepth_mask()
723 zdev->ap_dev->requestq_count; in zcrypt_qdepth_mask()
724 spin_unlock(&zdev->ap_dev->lock); in zcrypt_qdepth_mask()
731 struct zcrypt_device *zdev; in zcrypt_perdev_reqcnt() local
735 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_perdev_reqcnt()
736 spin_lock(&zdev->ap_dev->lock); in zcrypt_perdev_reqcnt()
737 reqcnt[AP_QID_DEVICE(zdev->ap_dev->qid)] = in zcrypt_perdev_reqcnt()
738 zdev->ap_dev->total_request_count; in zcrypt_perdev_reqcnt()
739 spin_unlock(&zdev->ap_dev->lock); in zcrypt_perdev_reqcnt()
746 struct zcrypt_device *zdev; in zcrypt_pendingq_count() local
750 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_pendingq_count()
751 spin_lock(&zdev->ap_dev->lock); in zcrypt_pendingq_count()
752 pendingq_count += zdev->ap_dev->pendingq_count; in zcrypt_pendingq_count()
753 spin_unlock(&zdev->ap_dev->lock); in zcrypt_pendingq_count()
761 struct zcrypt_device *zdev; in zcrypt_requestq_count() local
765 list_for_each_entry(zdev, &zcrypt_device_list, list) { in zcrypt_requestq_count()
766 spin_lock(&zdev->ap_dev->lock); in zcrypt_requestq_count()
767 requestq_count += zdev->ap_dev->requestq_count; in zcrypt_requestq_count()
768 spin_unlock(&zdev->ap_dev->lock); in zcrypt_requestq_count()
776 struct zcrypt_device *zdev; in zcrypt_count_type() local
780 list_for_each_entry(zdev, &zcrypt_device_list, list) in zcrypt_count_type()
781 if (zdev->user_space_type == type) in zcrypt_count_type()
1252 struct zcrypt_device *zdev; in zcrypt_disable_card() local
1255 list_for_each_entry(zdev, &zcrypt_device_list, list) in zcrypt_disable_card()
1256 if (AP_QID_DEVICE(zdev->ap_dev->qid) == index) { in zcrypt_disable_card()
1257 zdev->online = 0; in zcrypt_disable_card()
1258 ap_flush_queue(zdev->ap_dev); in zcrypt_disable_card()
1266 struct zcrypt_device *zdev; in zcrypt_enable_card() local
1269 list_for_each_entry(zdev, &zcrypt_device_list, list) in zcrypt_enable_card()
1270 if (AP_QID_DEVICE(zdev->ap_dev->qid) == index) { in zcrypt_enable_card()
1271 zdev->online = 1; in zcrypt_enable_card()