From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: linux-kernel@vger.kernel.org
Cc: Fruhwirth Clemens <clemens@endorphin.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
cryptoapi@lists.logix.cz, James Morris <jmorris@redhat.com>,
David Miller <davem@davemloft.net>, Andrew Morton <akpm@osdl.org>,
Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [3/many] acrypto: acrypto.h
Date: Mon, 7 Mar 2005 23:37:33 +0300 [thread overview]
Message-ID: <11102278533380@2ka.mipt.ru> (raw)
In-Reply-To: <1110227853321@2ka.mipt.ru>
--- /tmp/empty/acrypto.h 1970-01-01 03:00:00.000000000 +0300
+++ ./acrypto/acrypto.h 2005-03-07 20:35:36.000000000 +0300
@@ -0,0 +1,245 @@
+/*
+ * acrypto.h
+ *
+ * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
+ *
+ *
+ * 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
+ */
+
+#ifndef __ACRYPTO_H
+#define __ACRYPTO_H
+
+#define SCACHE_NAMELEN 32
+
+struct crypto_session_initializer;
+struct crypto_data;
+typedef void (*crypto_callback_t) (struct crypto_session_initializer *,
+ struct crypto_data *);
+
+struct crypto_device_stat
+{
+ __u64 scompleted;
+ __u64 sfinished;
+ __u64 sstarted;
+ __u64 kmem_failed;
+ __u64 pool_failed;
+};
+
+#ifdef __KERNEL__
+
+#include <linux/types.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/device.h>
+#include <linux/workqueue.h>
+#include <linux/mempool.h>
+
+#include <asm/scatterlist.h>
+
+#define DEBUG
+#ifdef DEBUG
+#define dprintk(f, a...) printk(f, ##a)
+#define dprintka(f, a...) printk(f, ##a)
+#else
+#define dprintk(f, a...)
+#define dprintka(f, a...)
+#endif
+
+extern void crypto_wake_lb(void);
+
+#define SESSION_COMPLETED (1<<15)
+#define SESSION_FINISHED (1<<14)
+#define SESSION_STARTED (1<<13)
+#define SESSION_PROCESSED (1<<12)
+#define SESSION_BINDED (1<<11)
+#define SESSION_BROKEN (1<<10)
+#define SESSION_FROM_CACHE (1<<9)
+
+#define session_completed(s) (s->ci.flags & SESSION_COMPLETED)
+#define complete_session(s) do {s->ci.flags |= SESSION_COMPLETED;} while(0)
+#define uncomplete_session(s) do {s->ci.flags &= ~SESSION_COMPLETED;} while (0)
+
+#define session_finished(s) (s->ci.flags & SESSION_FINISHED)
+#define finish_session(s) do {s->ci.flags |= SESSION_FINISHED;} while(0)
+#define unfinish_session(s) do {s->ci.flags &= ~SESSION_FINISHED;} while (0)
+
+#define session_started(s) (s->ci.flags & SESSION_STARTED)
+#define start_session(s) do {s->ci.flags |= SESSION_STARTED;} while(0)
+#define unstart_session(s) do {s->ci.flags &= ~SESSION_STARTED;} while (0)
+
+#define session_is_processed(s) (s->ci.flags & SESSION_PROCESSED)
+#define start_process_session(s) do {s->ci.flags |= SESSION_PROCESSED; s->ci.ptime = jiffies;} while(0)
+#define stop_process_session(s) do {s->ci.flags &= ~SESSION_PROCESSED; s->ci.ptime = jiffies - s->ci.ptime; crypto_wake_lb();} while (0)
+
+#define session_binded(s) (s->ci.flags & SESSION_BINDED)
+#define bind_session(s) do {s->ci.flags |= SESSION_BINDED;} while(0)
+#define unbind_session(s) do {s->ci.flags &= ~SESSION_BINDED;} while (0)
+#define sci_binded(ci) (ci->flags & SESSION_BINDED)
+
+#define session_broken(s) (s->ci.flags & SESSION_BROKEN)
+#define broke_session(s) do {s->ci.flags |= SESSION_BROKEN;} while(0)
+#define unbroke_session(s) do {s->ci.flags &= ~SESSION_BROKEN;} while (0)
+
+#define session_from_cache(s) (s->ci.flags & SESSION_FROM_CACHE)
+#define mark_session_from_cache(s) do {s->ci.flags |= SESSION_FROM_CACHE;} while(0)
+
+#define CRYPTO_MAX_PRIV_SIZE 1024
+
+#define DEVICE_BROKEN (1<<0)
+
+#define device_broken(dev) (dev->flags & DEVICE_BROKEN)
+#define broke_device(dev) do {dev->flags |= DEVICE_BROKEN;} while(0)
+#define repair_device(dev) do {dev->flags &= ~DEVICE_BROKEN;} while(0)
+
+struct crypto_capability {
+ u16 operation;
+ u16 type;
+ u16 mode;
+ u16 qlen;
+ u64 ptime;
+ u64 scomp;
+};
+
+struct crypto_session_initializer {
+ u16 operation;
+ u16 type;
+ u16 mode;
+ u16 priority;
+
+ u64 id;
+ u64 dev_id;
+
+ u32 flags;
+
+ u32 bdev;
+
+ u64 ptime;
+
+ crypto_callback_t callback;
+};
+
+struct crypto_data {
+ struct scatterlist *sg_src;
+ int sg_src_num;
+ struct scatterlist *sg_dst;
+ int sg_dst_num;
+ struct scatterlist *sg_key;
+ int sg_key_num;
+ struct scatterlist *sg_iv;
+ int sg_iv_num;
+
+ void *priv;
+ unsigned int priv_size;
+};
+
+struct crypto_device {
+ char name[SCACHE_NAMELEN];
+
+ spinlock_t session_lock;
+ struct list_head session_list;
+
+ u64 sid;
+ spinlock_t lock;
+
+ atomic_t refcnt;
+
+ u32 flags;
+
+ u32 id;
+
+ struct list_head cdev_entry;
+
+ void (*data_ready)(struct crypto_device *);
+
+ struct device_driver *driver;
+ struct device device;
+ struct class_device class_device;
+ struct completion dev_released;
+
+ spinlock_t stat_lock;
+ struct crypto_device_stat stat;
+
+ struct crypto_capability *cap;
+ int cap_number;
+
+ void *priv;
+
+ mempool_t *session_pool;
+ kmem_cache_t *session_cache;
+};
+
+struct crypto_route_head {
+ struct crypto_route *next;
+ struct crypto_route *prev;
+
+ __u32 qlen;
+ spinlock_t lock;
+};
+
+struct crypto_route {
+ struct crypto_route *next;
+ struct crypto_route *prev;
+
+ struct crypto_route_head *list;
+ struct crypto_device *dev;
+
+ struct crypto_session_initializer ci;
+};
+
+struct crypto_session {
+ struct list_head dev_queue_entry;
+ struct list_head main_queue_entry;
+
+ struct crypto_session_initializer ci;
+
+ struct crypto_data data;
+
+ spinlock_t lock;
+
+ struct work_struct work;
+
+ struct crypto_route_head route_list;
+
+ struct crypto_device *pool_dev;
+};
+
+struct crypto_session *crypto_session_alloc(struct crypto_session_initializer *, struct crypto_data *);
+struct crypto_session *crypto_session_create(struct crypto_session_initializer *, struct crypto_data *);
+void crypto_session_destroy(struct crypto_session *);
+void crypto_session_add(struct crypto_session *);
+void crypto_session_dequeue_main(struct crypto_session *);
+void __crypto_session_dequeue_main(struct crypto_session *);
+void __crypto_session_dequeue_route(struct crypto_session *);
+void crypto_session_dequeue_route(struct crypto_session *);
+
+void crypto_device_get(struct crypto_device *);
+void crypto_device_put(struct crypto_device *);
+struct crypto_device *crypto_device_get_name(char *);
+
+int __crypto_device_add(struct crypto_device *);
+int crypto_device_add(struct crypto_device *);
+void __crypto_device_remove(struct crypto_device *);
+void crypto_device_remove(struct crypto_device *);
+int match_initializer(struct crypto_device *, struct crypto_session_initializer *);
+int __match_initializer(struct crypto_capability *, struct crypto_session_initializer *);
+
+void crypto_session_insert_main(struct crypto_device *dev, struct crypto_session *s);
+void crypto_session_insert(struct crypto_device *dev, struct crypto_session *s);
+void __crypto_session_insert(struct crypto_device *dev, struct crypto_session *s);
+
+#endif /* __KERNEL__ */
+#endif /* __ACRYPTO_H */
next prev parent reply other threads:[~2005-03-07 20:29 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-07 20:37 [0/many] Acrypto - asynchronous crypto layer for linux kernel 2.6 Evgeniy Polyakov
2005-03-07 20:37 ` [??/many] list of files to be sent in a next couple of e-mails with small description Evgeniy Polyakov
2005-03-07 20:37 ` [??/many] acrypto benchmarks vs cryptoloop vs dm_crypt Evgeniy Polyakov
2005-03-07 20:37 ` [??/many] iok.c - simple example of the userspace acrypto usage [IOCTL] Evgeniy Polyakov
2005-03-07 20:37 ` [??/many] ucon_crypto.c - simple example of the userspace acrypto usage [DIRECT ACCESS] Evgeniy Polyakov
2005-03-07 20:37 ` [1/many] acrypto: Kconfig Evgeniy Polyakov
2005-03-07 20:37 ` [2/many] acrypto: Makefile Evgeniy Polyakov
2005-03-07 20:37 ` Evgeniy Polyakov [this message]
2005-03-07 20:37 ` [4/many] acrypto: async_provider.c Evgeniy Polyakov
2005-03-07 20:37 ` [5/many] acrypto: crypto_conn.c Evgeniy Polyakov
2005-03-07 20:37 ` [6/many] acrypto: crypto_conn.h Evgeniy Polyakov
2005-03-07 20:37 ` [7/many] acrypto: crypto_def.h Evgeniy Polyakov
2005-03-07 20:37 ` [8/many] acrypto: crypto_dev.c Evgeniy Polyakov
2005-03-07 20:37 ` [9/many] acrypto: crypto_lb.c Evgeniy Polyakov
2005-03-07 20:37 ` [10/many] acrypto: crypto_lb.h Evgeniy Polyakov
2005-03-07 20:37 ` [11/many] acrypto: crypto_main.c Evgeniy Polyakov
2005-03-07 20:37 ` [12/many] acrypto: crypto_route.h Evgeniy Polyakov
2005-03-07 20:37 ` [13/many] acrypto: crypto_stat.c Evgeniy Polyakov
2005-03-07 20:37 ` [14/many] acrypto: crypto_stat.h Evgeniy Polyakov
2005-03-07 20:37 ` [15/many] acrypto: crypto_user.c Evgeniy Polyakov
2005-03-07 20:37 ` [16/many] acrypto: crypto_user.h Evgeniy Polyakov
2005-03-07 20:37 ` [17/many] acrypto: crypto_user_direct.c Evgeniy Polyakov
2005-03-07 20:37 ` [18/many] acrypto: crypto_user_direct.h Evgeniy Polyakov
2005-03-07 20:37 ` [19/many] acrypto: crypto_user_ioctl.c Evgeniy Polyakov
2005-03-07 20:37 ` [20/many] acrypto: crypto_user_ioctl.h Evgeniy Polyakov
2005-03-07 20:37 ` [21/many] acrypto: simple_lb.c Evgeniy Polyakov
2005-03-07 20:37 ` [22/many] arch: alpha config Evgeniy Polyakov
2005-03-07 20:37 ` [23/many] arch: arm config Evgeniy Polyakov
2005-03-07 20:37 ` [24/many] arch: arm26 config Evgeniy Polyakov
2005-03-07 20:37 ` [25/many] arch: cris config Evgeniy Polyakov
2005-03-07 20:37 ` [26/many] arch: frv config Evgeniy Polyakov
2005-03-07 20:37 ` [27/many] arch: h8300 config Evgeniy Polyakov
2005-03-07 20:37 ` [28/many] arch: i386 config Evgeniy Polyakov
2005-03-07 20:37 ` [29/many] arch: ia64 config Evgeniy Polyakov
2005-03-07 20:37 ` [30/many] arch: m32r config Evgeniy Polyakov
2005-03-07 20:37 ` [31/many] arch: m68k config Evgeniy Polyakov
2005-03-07 20:37 ` [32/many] arch: m68knommu config Evgeniy Polyakov
2005-03-07 20:37 ` [33/many] arch: mips config Evgeniy Polyakov
2005-03-07 20:37 ` [34/many] arch: parisc config Evgeniy Polyakov
2005-03-07 20:37 ` [35/many] arch: ppc config Evgeniy Polyakov
2005-03-07 20:37 ` [36/many] arch: ppc64 config Evgeniy Polyakov
2005-03-07 20:37 ` [37/many] arch: s390 config Evgeniy Polyakov
2005-03-07 20:37 ` [38/many] arch: sh config Evgeniy Polyakov
2005-03-07 20:37 ` [39/many] arch: sh64 config Evgeniy Polyakov
2005-03-07 20:37 ` [40/many] arch: sparc config Evgeniy Polyakov
2005-03-07 20:37 ` [41/many] arch: sparc64 config Evgeniy Polyakov
2005-03-07 20:37 ` [42/many] arch: um config Evgeniy Polyakov
2005-03-07 20:37 ` [43/many] arch: v850 config Evgeniy Polyakov
2005-03-07 20:37 ` [44/many] arch: x86_64 config Evgeniy Polyakov
2005-03-07 20:37 ` [1/5] bd: Asynchronous block device Evgeniy Polyakov
2005-03-07 20:37 ` [2/5] bd: userspace utility to control asynchronous " Evgeniy Polyakov
2005-03-07 20:37 ` [4/5] bd: script for binding file and acrypto filters Evgeniy Polyakov
2005-03-07 20:37 ` [5/5] bd: script for unbinding any filters Evgeniy Polyakov
2005-03-08 15:16 ` [1/5] bd: Asynchronous block device Evgeniy Polyakov
2005-03-15 17:27 ` [16/many] acrypto: crypto_user.h Randy.Dunlap
2005-03-15 16:24 ` [11/many] acrypto: crypto_main.c Randy.Dunlap
2005-03-16 4:58 ` Evgeniy Polyakov
2005-03-08 18:02 ` [UPDATE PATCH 9/many] acrypto: crypto_lb.c Nishanth Aravamudan
2005-03-08 18:33 ` Evgeniy Polyakov
2005-03-10 19:18 ` [9/many] " Randy.Dunlap
2005-03-07 22:40 ` [8/many] acrypto: crypto_dev.c Nish Aravamudan
2005-03-07 23:14 ` Evgeniy Polyakov
2005-03-07 22:51 ` Nish Aravamudan
2005-03-07 23:27 ` Evgeniy Polyakov
2005-03-08 1:46 ` [UPDATE PATCH 8/many] " Nishanth Aravamudan
2005-03-08 9:40 ` Evgeniy Polyakov
2005-03-07 23:37 ` [8/many] " Randy.Dunlap
2005-03-08 0:05 ` Evgeniy Polyakov
2005-03-07 23:50 ` [3/many] acrypto: acrypto.h Randy.Dunlap
2005-03-08 0:34 ` Evgeniy Polyakov
2005-03-07 23:33 ` [1/many] acrypto: Kconfig Randy.Dunlap
2005-03-08 0:03 ` Evgeniy Polyakov
2005-03-07 21:13 ` [0/many] Acrypto - asynchronous crypto layer for linux kernel 2.6 Fruhwirth Clemens
2005-03-07 21:49 ` Evgeniy Polyakov
2005-03-08 13:24 ` Joshua Jackson
2005-03-10 10:27 ` Evgeniy Polyakov
2005-03-08 5:08 ` Kyle Moffett
2005-03-08 9:37 ` Evgeniy Polyakov
2005-03-08 12:22 ` Kyle Moffett
2005-03-08 13:07 ` Evgeniy Polyakov
2005-03-08 14:46 ` Kyle Moffett
2005-03-08 15:24 ` Evgeniy Polyakov
2005-03-10 12:42 ` Christophe Saout
2005-03-08 10:30 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11102278533380@2ka.mipt.ru \
--to=johnpol@2ka.mipt.ru \
--cc=akpm@osdl.org \
--cc=clemens@endorphin.org \
--cc=cryptoapi@lists.logix.cz \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jmorris@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.