Jivin Max lays it down ...
> Hello.
>
> I tried to port driver for micronas cypher chip from old ocf version to
> latest release. I'm not sure if I did it properly but at least it
> compiles now.
Sorry I've been so slow to respond, bit busy here on some stuff.
Comments included below.
> /* Runtime mode */
> static int c7108_crypto_mode = C7108_AES_CTRL_MODE_CTR;
> //static int c7108_crypto_mode = C7108_AES_CTRL_MODE_CBC;
You probably want CBC mode for OCF use, unless you don't ;-)
> static void
> skb_copy_bits_back(struct sk_buff *skb, int offset, caddr_t cp, int len)
> {
> int i;
> if (offset < skb_headlen(skb)) {
> memcpy(skb->data + offset, cp,
> min_t(int, skb_headlen(skb), len));
> len -= skb_headlen(skb);
> cp += skb_headlen(skb);
> }
> offset -= skb_headlen(skb);
> for (i = 0; len > 0 && i < skb_shinfo(skb)->nr_frags; i++) {
> if (offset < skb_shinfo(skb)->frags[i].size) {
> memcpy(page_address(skb_shinfo(skb)->frags[i].page) +
> skb_shinfo(skb)->frags[i].page_offset,
> cp, min_t(int,
> skb_shinfo(skb)->frags[i].size, len));
> len -= skb_shinfo(skb)->frags[i].size;
> cp += skb_shinfo(skb)->frags[i].size;
> }
> offset -= skb_shinfo(skb)->frags[i].size;
> }
> }
You can remove this function in newer OCF versions and switch to using
crypto_copyback instead, check the other driver for usage, it's
pretty simple.
crypto_copyback handles all the SKB/IOV/buffer variants for you.
> /* Start AES cipher */
> c7108_reg_wr16(C7108_AES_CTRL, ctrl | C7108_AES_GO);
>
> //printk("Ctrl: 0x%x\n", ctrl | C7108_AES_GO);
> do {
> /* TODO: interrupt mode */
> // printk("aes_stat=0x%x\n", stat);
> //udelay(100);
> } while ((cnt++ < 1000000) &&
> !((stat=c7108_reg_rd16(C7108_AES_CTRL))&C7108_AES_OP_DONE));
While polling is ok for a quick hack you will be much better off with
an interrupt based solution. Probably based on the hifn/safe or tolapai
drivers. Might be worth adding a call to schedule() inside this loop so
that you do not completely lockup the system if it takes a long time.
Otherwise it's a start towards getting something going.
The big thing is getting it to crypt something correctly.
I usually run something like:
echo test-data | openssl aes-128-cbc -k test-key | hd
using both cryptosoft and a new driver until I get the same result
from the new driver ;-)
Cheers,
Davidm
--
David McCullough, dav...@se..., Ph:+61 734352815
McAfee - SnapGear http://www.snapgear.com http://www.uCdot.org
|