2007-11-22 22:41:55

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 0/5] camellia: code shrink and 64-bit optimization

Patches start from 5 because pathches 1..4 are already
in cryptodev-2.6.

camellia5:
Remove unused macro params.
Use (u8)(expr) instead of (expr) & 0xff,
helps gcc to realize how to use simpler commands.
Move CAMELLIA_FLS macro closer to encrypt/decrypt routines.

camellia6:
unifies encrypt/decrypt routines for different key lengths.
This reduces module size by ~25%, with tiny (less than 1%)
speed impact.
Also collapses encrypt/decrypt into more readable
(visually shorter) form using macros.

camellia7:
Move "key XOR is end of F-function" code part into
camellia_setup_tail(), it is sufficiently similar
between camellia_setup128 and camellia_setup256.

camellia8:
Analogously to camellia7 patch, move
"absorb kw2 to other subkeys" and "absorb kw4 to other subkeys"
code parts into camellia_setup_tail(). This further reduces
source and object code size at the cost of two brances
in key setup code.

camellia9:
Adds 64-bit key setup, it is used if BITS_PER_LONG is 64.
30% faster key setup and 1k (7%) smaller module on amd64.

Code sizes:
64-bit:
dec hex filename
22786 5902 2.6.23.1.camellia4.t64/crypto/camellia.o
15670 3d36 2.6.23.1.camellia9.t64/crypto/camellia.o

32-bit:
29948 74fc 2.6.23.1.camellia4.t/crypto/camellia.o
18454 4816 2.6.23.1.camellia9.t/crypto/camellia.o

These patches apply cleanly to current cryptodev-2.6.
They should be applied in order.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


2007-11-22 22:45:57

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 2/5] camellia: code shrink #2

On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> camellia6:
> unifies encrypt/decrypt routines for different key lengths.
> This reduces module size by ~25%, with tiny (less than 1%)
> speed impact.
> Also collapses encrypt/decrypt into more readable
> (visually shorter) form using macros.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (407.00 B)
cryptodev-2.6.camellia6.diff (14.87 kB)
Download all attachments

2007-11-22 22:45:58

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 3/5] camellia: code shrink #3

On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> camellia7:
> Move "key XOR is end of F-function" code part into
> camellia_setup_tail(), it is sufficiently similar
> between camellia_setup128 and camellia_setup256.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (317.00 B)
cryptodev-2.6.camellia7.diff (11.59 kB)
Download all attachments

2007-11-22 22:46:00

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 4/5] camellia: code shrink #4

On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> camellia8:
> Analogously to camellia7 patch, move
> "absorb kw2 to other subkeys" and "absorb kw4 to other subkeys"
> code parts into camellia_setup_tail(). This further reduces
> source and object code size at the cost of two brances
> in key setup code.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (422.00 B)
cryptodev-2.6.camellia8.diff (7.51 kB)
Download all attachments

2007-11-22 22:46:01

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 5/5] camellia: 64-bit optimization

On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> camellia9:
> Adds 64-bit key setup, it is used if BITS_PER_LONG is 64.
> 30% faster key setup and 1k (7%) smaller module on amd64.

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (273.00 B)
cryptodev-2.6.camellia9.diff (13.76 kB)
Download all attachments

2007-11-22 22:46:03

by Denys Vlasenko

[permalink] [raw]
Subject: [PATCH 1/5] camellia: code shrink

On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> Patches start from 5 because pathches 1..4 are already
> in cryptodev-2.6.
>
> camellia5:
> Remove unused macro params.
> Use (u8)(expr) instead of (expr) & 0xff,
> helps gcc to realize how to use simpler commands.
> Move CAMELLIA_FLS macro closer to encrypt/decrypt routines.
>

Signed-off-by: Denys Vlasenko <[email protected]>
--
vda


Attachments:
(No filename) (436.00 B)
cryptodev-2.6.camellia5.diff (16.02 kB)
Download all attachments

2007-11-23 13:22:23

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 4/5] camellia: code shrink #4

On Thu, Nov 22, 2007 at 02:44:24PM -0800, Denys Vlasenko wrote:
> On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> > camellia8:
> > Analogously to camellia7 patch, move
> > "absorb kw2 to other subkeys" and "absorb kw4 to other subkeys"
> > code parts into camellia_setup_tail(). This further reduces
> > source and object code size at the cost of two brances
> > in key setup code.
>
> Signed-off-by: Denys Vlasenko <[email protected]>

Applied. Thanks.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2007-11-23 13:22:22

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 2/5] camellia: code shrink #2

On Thu, Nov 22, 2007 at 02:43:25PM -0800, Denys Vlasenko wrote:
> On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> > camellia6:
> > unifies encrypt/decrypt routines for different key lengths.
> > This reduces module size by ~25%, with tiny (less than 1%)
> > speed impact.
> > Also collapses encrypt/decrypt into more readable
> > (visually shorter) form using macros.
>
> Signed-off-by: Denys Vlasenko <[email protected]>

Also applied. Thanks Denys!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2007-11-23 13:22:25

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 3/5] camellia: code shrink #3

On Thu, Nov 22, 2007 at 02:43:55PM -0800, Denys Vlasenko wrote:
> On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> > camellia7:
> > Move "key XOR is end of F-function" code part into
> > camellia_setup_tail(), it is sufficiently similar
> > between camellia_setup128 and camellia_setup256.
>
> Signed-off-by: Denys Vlasenko <[email protected]>

Applied. Thanks.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2007-11-23 13:22:26

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 1/5] camellia: code shrink

On Thu, Nov 22, 2007 at 02:45:02PM -0800, Denys Vlasenko wrote:
> On Thursday 22 November 2007 14:41, Denys Vlasenko wrote:
> > Patches start from 5 because pathches 1..4 are already
> > in cryptodev-2.6.
> >
> > camellia5:
> > Remove unused macro params.
> > Use (u8)(expr) instead of (expr) & 0xff,
> > helps gcc to realize how to use simpler commands.
> > Move CAMELLIA_FLS macro closer to encrypt/decrypt routines.
> >
>
> Signed-off-by: Denys Vlasenko <[email protected]>

Patch applied.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt