mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier.adi@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] add checksum selftest
Date: Wed, 24 Jun 2009 10:45:33 -0400	[thread overview]
Message-ID: <8bd0f97a0906240745t3a11329fg3ffc6dfb0aa3dec5@mail.gmail.com> (raw)
In-Reply-To: <200906241614.02615.arnd@arndb.de>

On Wed, Jun 24, 2009 at 10:14, Arnd Bergmann wrote:
> On Wednesday 24 June 2009, Mike Frysinger wrote:
>> +/*
>> + * The do_csum() interface is "internal" to the generic checksum code.
>> + * Do not require it if the arch has not switched over.
>> + */
>> +extern unsigned short do_csum(const unsigned char *buff, int len);
>
> Just nitpicking: this prototype should to into asm-generic/checksum.h,
> extern declarations have no place in .c files.

yeah, i meant to move that after the last discussion, but forgot

>> +static unsigned char __initdata do_csum_data1[] = {
>> +     0x20,
>> +};
>> +static unsigned char __initdata do_csum_data2[] = {
>> +     0x0d, 0x0a,
>> +};
>> +static unsigned char __initdata do_csum_data3[] = {
>> +     0xff, 0xfb, 0x01,
>> +};
>
> You define separate test vectors for each of the three
> cases, which looks like it could be optimized by reusing
> the same test vectors for each case.

i'm not really familiar with the interfaces to figure out how to do
this ... i just added some printks to dump arguments/buffers and then
copied & pasted ones that looked pretty different

>> +static struct csum_partial_data __initdata csum_partial_data[] = {
>> +     CSUM_PARTIAL_DATA(1,  0x00000074, 0x0),
>> +     CSUM_PARTIAL_DATA(2,  0x00000a0d, 0x0),
>> +     CSUM_PARTIAL_DATA(3,  0x0000fe00, 0x0),
>> +     CSUM_PARTIAL_DATA(5,  0x00005084, 0x0),
>> +     CSUM_PARTIAL_DATA(8,  0x1101eefe, 0x11016a80),
>> +     CSUM_PARTIAL_DATA(8b, 0x00008781, 0x847e),
>> +     CSUM_PARTIAL_DATA(9,  0x1101eefe, 0x11016b80),
>> +};
>
> For partial checksums, the result has to be folded into a 16-bit
> number using csum_fold(), because csum_partial and other functions
> return a 32-bit __wsum that can take many equivalent values taht
> are all correct.

i hear your words, but i understand them not ;)

>> +static int __init csum_tcpudp_nofold_selftest(void)
>> +{
>> +     int i, ret;
>> +     unsigned short tret, eret;
>> +
>> +     ret = 0;
>> +     for (i = 0; i < ARRAY_SIZE(csum_tcpudp_nofold_data); ++i) {
>> +             eret = le16_to_cpu(csum_tcpudp_nofold_data[i].ret);
>> +             tret = csum_tcpudp_nofold(
>> +                     csum_tcpudp_nofold_data[i].saddr,
>> +                     csum_tcpudp_nofold_data[i].daddr,
>> +                     csum_tcpudp_nofold_data[i].len,
>> +                     csum_tcpudp_nofold_data[i].proto,
>> +                     csum_tcpudp_nofold_data[i].sum);
>> +             if (tret != eret) {
>> +                     pr_err("%s: test %i: %#x != %#x: FAIL\n",
>> +                             __func__, i, tret, eret);
>> +                     ret = 1;
>> +             }
>> +     }
>> +
>> +     return ret;
>> +}
>
> same here, but you can easily use csum_tcpudp_magic() instead of
> csum_tcpudp_nofold here.

this introduces redirection that would be annoying for people who
implement just csum_tcpudp_nofold() (like the Blackfin arch).  i dont
have a problem extending the test to also cover csum_tcpudp_magic(),
but i'd like to keep the csum_tcpudp_nofold() invocation as well.
-mike

  reply	other threads:[~2009-06-24 14:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-24 13:31 Mike Frysinger
2009-06-24 14:14 ` Arnd Bergmann
2009-06-24 14:45   ` Mike Frysinger [this message]
2009-06-24 15:24     ` Arnd Bergmann
2009-06-24 19:43       ` Mike Frysinger
2009-06-25 10:55         ` Arnd Bergmann
2009-07-06  8:12           ` Michal Simek
2009-07-06  8:24             ` Mike Frysinger
2009-07-06  8:51               ` Michal Simek

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=8bd0f97a0906240745t3a11329fg3ffc6dfb0aa3dec5@mail.gmail.com \
    --to=vapier.adi@gmail.com \
    --cc=arnd@arndb.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®