1 ###########################
2 README - ocf-linux-20100530
3 ###########################
5 This README provides instructions for getting ocf-linux compiled and
6 operating in a generic linux environment. Other information on the project
7 can be found at the home page:
9 http://ocf-linux.sourceforge.net/
11 Embedded systems and applications requiring userspace acceleration will need
12 to patch the kernel source to get full OCF support. See "Adding OCF to
13 linux source" below. Otherwise the "OCF Quickstart" that follows is the
14 easiest way to get started.
16 If your goal is to accelerate Openswan on Ubuntu or CentOS, you may find
17 that the required binaries are already available on openswan.org:
19 ftp://ftp.openswan.org/ocf/
20 ftp://ftp.openswan.org/openswan/binaries/ubuntu/
22 #####################################################
23 OCF Quickstart for Ubuntu/Others (including Openswan)
24 #####################################################
26 This section provides instructions on how to quickly add kernel only support
27 for OCF to a GNU/Linux system. It is only suitable for in-kernel use such as
30 If the target is an embedded system, or, userspace acceleration of
31 applications such as OpenVPN and OpenSSL, the section below titled
32 "Adding OCF to linux source" is more appropriate.
34 Before building kernel only support for OCF ensure that the appropriate
35 linux-headers package is installed:
40 OCF_DIR=`pwd` # remember where OCF sources were built
42 At this point the ocf, cryptosoft, ocfnull, hifn7751 and ocf-bench modules
43 should have been built and installed. The OCF installation can be tested
44 with the following commands:
51 The final modprobe of ocf-bench will fail, this is intentional as ocf-bench
52 is a short lived module that tests in-kernel performance of OCF. If
53 everything worked correctly the "dmesg | tail -5" should include a line
56 [ 583.128741] OCF: 45133 requests of 1488 bytes in 251 jiffies (535.122 Mbps)
58 This shows the in-kernel performance of OCF using the cryptosoft driver.
59 For addition driver load options, see "How to load the OCF modules" below.
61 If the intention is to run an OCF accelerated Openswan (KLIPS/MAST) then use
62 these steps to compile openswan downloaded from openswan.org (2.6.34 or later).
64 tar xf openswan-2.6.34.tar.gz
67 make KERNELSRC=/lib/modules/`uname -r`/build \
68 KBUILD_EXTRA_SYMBOLS=$OCF_DIR/Module.symvers \
69 MODULE_DEF_INCLUDE=`pwd`/packaging/ocf/config-all.hmodules \
70 MODULE_DEFCONFIG=`pwd`/packaging/ocf/defconfig \
72 sudo make KERNELSRC=/lib/modules/`uname -r`/build \
73 KBUILD_EXTRA_SYMBOLS=$OCF_DIR/Module.symvers \
74 MODULE_DEF_INCLUDE=`pwd`/packaging/ocf/config-all.hmodules \
75 MODULE_DEFCONFIG=`pwd`/packaging/ocf/defconfig \
78 The rest of this document is only required for more complex build
81 ##########################
82 Adding OCF to linux source
83 ##########################
85 It is recommended that OCF be built as modules as it increases the
86 flexibility and ease of debugging the system.
88 Ensure that the system has /dev/crypto for userspace access to OCF:
90 mknod /dev/crypto c 10 70
92 Generate the kernel patches and apply the appropriate one.
97 This will provide three files:
100 linux-2.6.*-ocf.patch
103 If either of the first two patches applies to the targets kernel, then one
104 of the following as required:
106 cd linux-2.X.Y; patch -p1 < linux-2.4.*-ocf.patch
107 cd linux-2.6.Y; patch -p1 < linux-2.6.*-ocf.patch
109 Otherwise, locate the appropriate kernel patch in the patches directory and
110 apply that as well as the ocf-linux-base.patch using '-p1'.
112 When using a linux-2.4 system on a non-x86 platform, the following may be
113 required to build cryptosoft:
115 cp linux-2.X.x/include/asm-i386/kmap_types.h linux-2.X.x/include/asm-YYY
117 When using cryptosoft, for simplicity, enable all the crypto support in the
118 kernel except for the test driver. Likewise for the OCF options. Do not
119 enable OCF crypto drivers for HW that is not present (for example the ixp4xx
120 driver will not compile on non-Xscale systems).
122 Make sure that cryptodev.h from the ocf directory is installed as
123 crypto/cryptodev.h in an include directory that is used for building
124 applications for the target platform. For example on a host system that
127 /usr/include/crypto/cryptodev.h
129 Patch the openssl-0.9.8r code the openssl-0.9.8r.patch from the patches
130 directory. There are many older patch versions in the patches directory
133 The openssl patches provide the following functionality:
135 * enables --with-cryptodev for non BSD systems
136 * adds -cpu option to openssl speed for calculating CPU load under linux
137 * fixes null pointer in openssl speed multi thread output.
138 * fixes test keys to work with linux crypto's more stringent key checking.
139 * adds MD5/SHA acceleration (Ronen Shitrit), only enabled with the
140 --with-cryptodev-digests option
141 * fixes bug in engine code caching.
143 Build the crypto-tools directory for the target to obtain a userspace
144 testing tool call cryptotest.
146 ###########################
147 How to load the OCF modules
148 ###########################
150 First insert the base modules (cryptodev is optional, it is only used
151 for userspace acceleration):
156 Load the software OCF driver with:
160 and zero or more of the OCF HW drivers with:
167 All the drivers take a debug option to enable verbose debug so that
168 OCF operation may be observed via "dmesg" or the console. For debug
171 modprobe ocf crypto_debug=1
172 modprobe cryptodev cryptodev_debug=1
173 modprobe cryptosoft swcr_debug=1
175 More than one OCF crypto driver may be loaded but then there is no
176 guarantee as to which will be used (other than a preference for HW
177 drivers over SW drivers by most applications).
179 It is also possible to enable debug at run time on linux-2.6 systems
182 echo 1 > /sys/module/ocf/parameters/crypto_debug
183 echo 1 > /sys/module/cryptodev/parameters/cryptodev_debug
184 echo 1 > /sys/module/cryptosoft/parameters/swcr_debug
185 echo 1 > /sys/module/hifn7751/parameters/hifn_debug
186 echo 1 > /sys/module/safe/parameters/safe_debug
187 echo 1 > /sys/module/ixp4xx/parameters/ixp_debug
190 The ocf-bench driver accepts the following parameters:
192 request_q_len - Maximum number of outstanding requests to OCF
193 request_num - run for at least this many requests
194 request_size - size of each request (multiple of 16 bytes recommended)
195 request_batch - enable OCF request batching
196 request_cbimm - enable OCF immediate callback on completion
200 modprobe ocf-bench request_size=1024 request_cbimm=0
202 #######################
203 Testing the OCF support
204 #######################
206 run "cryptotest", it should do a short test for a couple of
207 des packets. If it does everything is working.
209 If this works, then ssh will use the driver when invoked as:
211 ssh -c 3des username@host
213 to see for sure that it is operating, enable debug as defined above.
215 To get a better idea of performance run:
219 There are more options to cryptotest, see the help.
221 It is also possible to use openssl to test the speed of the crypto
224 openssl speed -evp des -engine cryptodev -elapsed
225 openssl speed -evp des3 -engine cryptodev -elapsed
226 openssl speed -evp aes128 -engine cryptodev -elapsed
228 and multiple threads (10) with:
230 openssl speed -evp des -engine cryptodev -elapsed -multi 10
231 openssl speed -evp des3 -engine cryptodev -elapsed -multi 10
232 openssl speed -evp aes128 -engine cryptodev -elapsed -multi 10
234 for public key testing you can try:
237 openssl speed -engine cryptodev rsa -elapsed
238 openssl speed -engine cryptodev dsa -elapsed
241 #############################
244 # david_mccullough@mcafee.com
246 #############################