/* * provider.c * * Copyright (c) 2004 Evgeniy Polyakov * * * 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 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include "acrypto.h" #include "crypto_stat.h" static int prov_data_ready_reentry; static void prov_data_ready(struct crypto_device *dev); static struct crypto_capability prov_caps[] = { {0, 0, 0, 1000}, {1, 1, 1, 1000}, {2, 2, 2, 1000}}; static int prov_cap_number = sizeof(prov_caps)/sizeof(prov_caps[0]); static struct crypto_device pdev = { .name = "test_provider", .data_ready = prov_data_ready, .cap = &prov_caps[0], }; static void prov_data_ready(struct crypto_device *dev) { struct crypto_session *s, *n; if (prov_data_ready_reentry) return; prov_data_ready_reentry++; //spin_lock_bh(&dev->session_lock); list_for_each_entry_safe(s, n, &dev->session_list, dev_queue_entry) { if (!session_completed(s)) { dprintk("Completing session %llu [%llu] in %s.\n", s->ci.id, s->ci.dev_id, pdev.name); crypto_stat_complete_inc(s); complete_session(s); } } //spin_unlock_bh(&dev->session_lock); prov_data_ready_reentry--; } int prov_init(void) { int err; pdev.cap_number = prov_cap_number; err = crypto_device_add(&pdev); if (err) return err; dprintk(KERN_INFO "Test crypto provider module %s is loaded.\n", pdev.name); return 0; } void prov_fini(void) { crypto_device_remove(&pdev); dprintk(KERN_INFO "Test crypto provider module %s is unloaded.\n", pdev.name); } module_init(prov_init); module_exit(prov_fini); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Evgeniy Polyakov "); MODULE_DESCRIPTION("Test crypto module provider.");