2007-11-26 07:11:20

by cheng renquan

[permalink] [raw]
Subject: [PATCH 1/2] crypto test: use print_hex_dump from <linux/kernel.h>

these utilities implemented in lib/hexdump.c are more handy, please use this.

Cc: Randy Dunlap <[email protected]>
Signed-off-by: Denis Cheng <[email protected]>
---
crypto/tcrypt.c | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 24141fb..8766023 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -81,14 +81,6 @@ static char *check[] = {
"camellia", "seed", NULL
};

-static void hexdump(unsigned char *buf, unsigned int len)
-{
- while (len--)
- printk("%02x", *buf++);
-
- printk("\n");
-}
-
static void tcrypt_complete(struct crypto_async_request *req, int err)
{
struct tcrypt_result *res = req->data;
@@ -156,7 +148,8 @@ static void test_hash(char *algo, struct hash_testvec *template,
goto out;
}

- hexdump(result, crypto_hash_digestsize(tfm));
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, result, crypto_hash_digestsize(tfm), 1);
+
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_hash_digestsize(tfm)) ?
@@ -203,7 +196,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
goto out;
}

- hexdump(result, crypto_hash_digestsize(tfm));
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, result, crypto_hash_digestsize(tfm), 1);
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_hash_digestsize(tfm)) ?
@@ -319,7 +312,7 @@ static void test_cipher(char *algo, int enc,
}

q = kmap(sg_page(&sg[0])) + sg[0].offset;
- hexdump(q, cipher_tv[i].rlen);
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, q, cipher_tv[i].rlen, 1);

printk("%s\n",
memcmp(q, cipher_tv[i].result,
@@ -393,7 +386,7 @@ static void test_cipher(char *algo, int enc,
for (k = 0; k < cipher_tv[i].np; k++) {
printk("page %u\n", k);
q = kmap(sg_page(&sg[k])) + sg[k].offset;
- hexdump(q, cipher_tv[i].tap[k]);
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, q, cipher_tv[i].tap[k], 1);
printk("%s\n",
memcmp(q, cipher_tv[i].result + temp,
cipher_tv[i].tap[k]) ? "fail" :
@@ -839,7 +832,7 @@ static void test_deflate(void)
printk("fail: ret=%d\n", ret);
continue;
}
- hexdump(result, dlen);
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, result, dlen, 1);
printk("%s (ratio %d:%d)\n",
memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
ilen, dlen);
@@ -870,7 +863,7 @@ static void test_deflate(void)
printk("fail: ret=%d\n", ret);
continue;
}
- hexdump(result, dlen);
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1, result, dlen, 1);
printk("%s (ratio %d:%d)\n",
memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
ilen, dlen);
--
1.5.3.5


2007-11-26 14:39:39

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 1/2] crypto test: use print_hex_dump from <linux/kernel.h>

On Mon, Nov 26, 2007 at 03:13:02PM +0800, Denis Cheng wrote:
> these utilities implemented in lib/hexdump.c are more handy, please use this.
>
> Cc: Randy Dunlap <[email protected]>
> Signed-off-by: Denis Cheng <[email protected]>

OK this is pretty nice. But you just missed out because the
GCM patches that just went in added more hexdump uses :)

So could you please refresh your patch against the latest cryptodev
tree? Please also clamp those long lines to 80 characters.

On an unrelated note, lib/hexdump.c should not print 8-bit text
even though they pass the is_print test. They just turn up as
crap on Unicode terminals.

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-26 17:28:35

by cheng renquan

[permalink] [raw]
Subject: [PATCH] [RESEND] crypto test: use print_hex_dump from <linux/kernel.h> instead

this patch is against cryptodev-2.6, and have passed scripts/checkpatch.pl

KERN_DEBUG is stripped out, this acts more like the original in tcrypto.c

and the last parameter "bool ascii" set to zero to disable ascii output,
this could keep it happy on Unicode terminals.

Cc: Randy Dunlap <[email protected]>
Signed-off-by: Denis Cheng <[email protected]>
---
crypto/tcrypt.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 24141fb..665aa87 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -81,14 +81,6 @@ static char *check[] = {
"camellia", "seed", NULL
};

-static void hexdump(unsigned char *buf, unsigned int len)
-{
- while (len--)
- printk("%02x", *buf++);
-
- printk("\n");
-}
-
static void tcrypt_complete(struct crypto_async_request *req, int err)
{
struct tcrypt_result *res = req->data;
@@ -156,7 +148,9 @@ static void test_hash(char *algo, struct hash_testvec *template,
goto out;
}

- hexdump(result, crypto_hash_digestsize(tfm));
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET, 16, 1,
+ result, crypto_hash_digestsize(tfm), 0);
+
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_hash_digestsize(tfm)) ?
@@ -203,7 +197,9 @@ static void test_hash(char *algo, struct hash_testvec *template,
goto out;
}

- hexdump(result, crypto_hash_digestsize(tfm));
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ result, crypto_hash_digestsize(tfm), 0);
printk("%s\n",
memcmp(result, hash_tv[i].digest,
crypto_hash_digestsize(tfm)) ?
@@ -319,7 +315,9 @@ static void test_cipher(char *algo, int enc,
}

q = kmap(sg_page(&sg[0])) + sg[0].offset;
- hexdump(q, cipher_tv[i].rlen);
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ q, cipher_tv[i].rlen, 0);

printk("%s\n",
memcmp(q, cipher_tv[i].result,
@@ -393,7 +391,9 @@ static void test_cipher(char *algo, int enc,
for (k = 0; k < cipher_tv[i].np; k++) {
printk("page %u\n", k);
q = kmap(sg_page(&sg[k])) + sg[k].offset;
- hexdump(q, cipher_tv[i].tap[k]);
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ q, cipher_tv[i].tap[k], 0);
printk("%s\n",
memcmp(q, cipher_tv[i].result + temp,
cipher_tv[i].tap[k]) ? "fail" :
@@ -839,7 +839,8 @@ static void test_deflate(void)
printk("fail: ret=%d\n", ret);
continue;
}
- hexdump(result, dlen);
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET, 16, 1,
+ result, dlen, 0);
printk("%s (ratio %d:%d)\n",
memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
ilen, dlen);
@@ -870,7 +871,8 @@ static void test_deflate(void)
printk("fail: ret=%d\n", ret);
continue;
}
- hexdump(result, dlen);
+ print_hex_dump("", "", DUMP_PREFIX_OFFSET, 16, 1,
+ result, dlen, 0);
printk("%s (ratio %d:%d)\n",
memcmp(result, tv[i].output, dlen) ? "fail" : "pass",
ilen, dlen);
--
1.5.3.4

2007-11-26 18:03:05

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from <linux/kernel.h> instead

On Tue, 2007-11-27 at 01:28 +0800, Denis Cheng wrote:
> -static void hexdump(unsigned char *buf, unsigned int len)
> -{
> - while (len--)
> - printk("%02x", *buf++);
> -
> - printk("\n");
> -}

#define hexdump(buf, len) \
print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, \
(buf), (len), false)

requires no other changes.

2007-11-27 01:05:55

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from <linux/kernel.h> instead

On Tue, Nov 27, 2007 at 01:28:15AM +0800, Denis Cheng wrote:
> this patch is against cryptodev-2.6, and have passed scripts/checkpatch.pl
>
> KERN_DEBUG is stripped out, this acts more like the original in tcrypto.c
>
> and the last parameter "bool ascii" set to zero to disable ascii output,
> this could keep it happy on Unicode terminals.
>
> Cc: Randy Dunlap <[email protected]>
> Signed-off-by: Denis Cheng <[email protected]>

Sorry, it still doesn't compile because it doesn't change test_aead.
Perhaps you need to pull cryptodev again?

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-27 01:35:47

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from <linux/kernel.h> instead

On Mon, Nov 26, 2007 at 10:01:44AM -0800, Joe Perches wrote:
> On Tue, 2007-11-27 at 01:28 +0800, Denis Cheng wrote:
> > -static void hexdump(unsigned char *buf, unsigned int len)
> > -{
> > - while (len--)
> > - printk("%02x", *buf++);
> > -
> > - printk("\n");
> > -}
>
> #define hexdump(buf, len) \
> print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, \
> (buf), (len), false)
>
> requires no other changes.

Yes that's a good idea. Denis could you do another patch with
this, preferably as a static inline function? That way you don't
even need to worry about test_aead.

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-27 02:45:29

by cheng renquan

[permalink] [raw]
Subject: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

Cc: Randy Dunlap <[email protected]>
Signed-off-by: Denis Cheng <[email protected]>
---
this is against the lastest cryptodev tree.

crypto/tcrypt.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1e12b86..ae762c2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -87,12 +87,11 @@ static char *check[] = {
"camellia", "seed", "salsa20", NULL
};

-static void hexdump(unsigned char *buf, unsigned int len)
+static inline void hexdump(unsigned char *buf, unsigned int len)
{
- while (len--)
- printk("%02x", *buf++);
-
- printk("\n");
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, 0);
}

static void tcrypt_complete(struct crypto_async_request *req, int err)
--
1.5.3.5

2007-11-27 03:13:10

by Richard Knutsson

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

Denis Cheng wrote:
> Cc: Randy Dunlap <[email protected]>
> Signed-off-by: Denis Cheng <[email protected]>
> ---
> this is against the lastest cryptodev tree.
>
> crypto/tcrypt.c | 9 ++++-----
> 1 files changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
> index 1e12b86..ae762c2 100644
> --- a/crypto/tcrypt.c
> +++ b/crypto/tcrypt.c
> @@ -87,12 +87,11 @@ static char *check[] = {
> "camellia", "seed", "salsa20", NULL
> };
>
> -static void hexdump(unsigned char *buf, unsigned int len)
> +static inline void hexdump(unsigned char *buf, unsigned int len)
> {
> - while (len--)
> - printk("%02x", *buf++);
> -
> - printk("\n");
> + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
> + 16, 1,
> + buf, len, 0);
>
Not important, but why use '0' instead of 'false'?
> }
>
> static void tcrypt_complete(struct crypto_async_request *req, int err)
>
cu
Richard Knutsson

2007-11-27 05:03:31

by cheng renquan

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

On Nov 27, 2007 10:58 AM, Richard Knutsson <[email protected]> wrote:
...
> > + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
> > + 16, 1,
> > + buf, len, 0);
> >
> Not important, but why use '0' instead of 'false'?
after read http://lkml.org/lkml/2006/7/27/281, I agreed with you.
this is refreshed patch against the lastest cryptodev tree.

Cc: Randy Dunlap <[email protected]>
Signed-off-by: Denis Cheng <[email protected]>
---
crypto/tcrypt.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 1e12b86..ae762c2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -87,12 +87,11 @@ static char *check[] = {
"camellia", "seed", "salsa20", NULL
};

-static void hexdump(unsigned char *buf, unsigned int len)
+static inline void hexdump(unsigned char *buf, unsigned int len)
{
- while (len--)
- printk("%02x", *buf++);
-
- printk("\n");
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
}

static void tcrypt_complete(struct crypto_async_request *req, int err)

--
Denis Cheng

2007-11-27 09:26:22

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

On Tue, 27 Nov 2007 13:03:29 +0800 "rae l" <[email protected]> wrote:

> -static void hexdump(unsigned char *buf, unsigned int len)
> +static inline void hexdump(unsigned char *buf, unsigned int len)
> {
> - while (len--)
> - printk("%02x", *buf++);
> -
> - printk("\n");
> + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
> + 16, 1,
> + buf, len, false);
> }

uninlining this function shrinks crypto/tcrypt.o's .text from 20,009 bytes
down to 19,701.

inlining is almost always wrong.

2007-11-29 11:13:37

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

On Tue, Nov 27, 2007 at 01:26:22AM -0800, Andrew Morton wrote:
> On Tue, 27 Nov 2007 13:03:29 +0800 "rae l" <[email protected]> wrote:
>
> > -static void hexdump(unsigned char *buf, unsigned int len)
> > +static inline void hexdump(unsigned char *buf, unsigned int len)
> > {
> > - while (len--)
> > - printk("%02x", *buf++);
> > -
> > - printk("\n");
> > + print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
> > + 16, 1,
> > + buf, len, false);
> > }
>
> uninlining this function shrinks crypto/tcrypt.o's .text from 20,009 bytes
> down to 19,701.
>
> inlining is almost always wrong.

I agree. Please do as Andrew suggests and resubmit.

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-30 01:20:36

by cheng renquan

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

On Nov 29, 2007 7:13 PM, Herbert Xu <[email protected]> wrote:
...
> > uninlining this function shrinks crypto/tcrypt.o's .text from 20,009 bytes
> > down to 19,701.
> >
> > inlining is almost always wrong.
>
> I agree. Please do as Andrew suggests and resubmit.
inline disabled.

Cc: Randy Dunlap <[email protected]>
Signed-off-by: Denis Cheng <[email protected]>
---

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 24141fb..13efc72 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -83,10 +83,9 @@ static char *check[] = {

static void hexdump(unsigned char *buf, unsigned int len)
{
- while (len--)
- printk("%02x", *buf++);
-
- printk("\n");
+ print_hex_dump(KERN_CONT, "", DUMP_PREFIX_OFFSET,
+ 16, 1,
+ buf, len, false);
}

static void tcrypt_complete(struct crypto_async_request *req, int err)

--
Denis Cheng

2007-11-30 06:00:19

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] [RESEND] crypto test: use print_hex_dump from kernel.h instead

On Fri, Nov 30, 2007 at 09:20:34AM +0800, rae l wrote:
>
> Cc: Randy Dunlap <[email protected]>
> Signed-off-by: Denis Cheng <[email protected]>

Patch applied. Thanks a lot Denis!
--
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