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,
	uclinux-dist-devel@blackfin.uclinux.org,
	Michal Simek <monstr@monstr.eu>, Paul Mundt <lethal@linux-sh.org>
Subject: Re: [PATCH 05/17] Blackfin: convert to generic checksum code
Date: Fri, 19 Jun 2009 09:12:12 -0400	[thread overview]
Message-ID: <8bd0f97a0906190612n687cdbbt1e752997acb68e49@mail.gmail.com> (raw)
In-Reply-To: <200906191433.34608.arnd@arndb.de>

[-- Attachment #1: Type: text/plain, Size: 650 bytes --]

On Fri, Jun 19, 2009 at 08:33, Arnd Bergmann wrote:
> On Friday 19 June 2009, Mike Frysinger wrote:
>> On Fri, Jun 19, 2009 at 05:05, Arnd Bergmann wrote:
>> > x86 and blackfin are both little-endian, so your variant is correct
>> > there. They add the 0x01 to the low byte of the 16-bit word, while
>> > on big-endian machines, you have to add it to the high byte.
>>
>> can we think of enough simple examples to through together an optional
>> boot-time self test ?
>
> sounds like a good idea.

how about the attached

> lib/checksum.c: Fix another endianess bug

hrm, still not quite :/

the attached test code shows failures in every case
-mike

[-- Attachment #2: checksum-selftest.c --]
[-- Type: text/x-csrc, Size: 3194 bytes --]

/*
 * Networking checksum self checks.
 *
 * Licensed under the GPL-2.
 */

#define pr_fmt(fmt) "csum-selftest: " fmt

#include <linux/kernel.h>
#include <net/checksum.h>

extern unsigned short do_csum(const unsigned char *buff, int len);

struct do_csum_data {
	unsigned short ret;
	unsigned char *buf;
	int len;
};
#define DO_CSUM_DATA(_num, _ret) \
{	\
	.ret = _ret, \
	.buf = do_csum_data##_num, \
	.len = ARRAY_SIZE(do_csum_data##_num), \
}
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,
};
static unsigned char __initdata do_csum_data5[] = {
	0x67, 0x72, 0x5d, 0x0d, 0x00,
};
static unsigned char __initdata do_csum_data7[] = {
	0x20, 0x20, 0x20, 0x35, 0x37, 0x20, 0x20,
};
static unsigned char __initdata do_csum_data255[] = {
	0x20, 0x34, 0x34, 0x34, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2d,
	0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x68, 0x20, 0x0d, 0x0a, 0x20,
	0x20, 0x31, 0x30, 0x35, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20,
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x34, 0x34, 0x20, 0x53, 0x20,
	0x20, 0x20, 0x20, 0x2f, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x69, 0x6e,
	0x65, 0x74, 0x64, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30, 0x36,
	0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x34, 0x33, 0x36, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f,
	0x73, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x79, 0x73, 0x6c, 0x6f, 0x67,
	0x64, 0x20, 0x2d, 0x6e, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30,
	0x37, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20, 0x34, 0x33, 0x32, 0x20, 0x52, 0x20, 0x20, 0x20, 0x20,
	0x2f, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x6b, 0x6c, 0x6f, 0x67, 0x64,
	0x20, 0x2d, 0x6e, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31, 0x30, 0x38,
	0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20, 0x33, 0x32, 0x20, 0x53, 0x20, 0x20, 0x20, 0x20, 0x2f,
	0x62, 0x69, 0x6e, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, 0x64, 0x6f,
	0x67, 0x64, 0x20, 0x2d, 0x66, 0x20, 0x2d, 0x73, 0x20, 0x0d, 0x0a,
	0x20, 0x20, 0x31, 0x30, 0x39, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20,
	0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x36, 0x20, 0x52,
	0x20, 0x20, 0x20, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x2f, 0x74, 0x65,
	0x6c, 0x6e, 0x65, 0x74, 0x64, 0x20, 0x0d, 0x0a, 0x20, 0x20, 0x31,
	0x31, 0x30, 0x20, 0x72, 0x6f, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20,
	0x20, 0x20
};
static struct do_csum_data __initdata do_csum_data[] = {
	DO_CSUM_DATA(1, 0x0020),
	DO_CSUM_DATA(2, 0xfc00),
	DO_CSUM_DATA(3, 0x0a0d),
	DO_CSUM_DATA(5, 0x7fc4),
	DO_CSUM_DATA(7, 0x7597),
	DO_CSUM_DATA(255, 0x4f96),
};

static int __init do_csum_selftest(void)
{
	int i, ret;
	unsigned short tret;

	ret = 0;
	for (i = 0; i < ARRAY_SIZE(do_csum_data); ++i) {
		tret = do_csum(do_csum_data[i].buf, do_csum_data[i].len);
		if (tret != do_csum_data[i].ret) {
			pr_err("%s: test %i: %#x != %#x: FAIL\n",
				__func__, i, tret, do_csum_data[i].ret);
			ret = 1;
		}
	}

	return ret;
}

static int __init csum_selftest_init(void)
{
	int ret = do_csum_selftest();

	if (!ret)
		pr_info("all tests passed!\n");

	return 0;
}
module_init(csum_selftest_init);

  reply	other threads:[~2009-06-19 13:12 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-14 12:01 [PATCH 00/17] Blackfin arch conversion to asm-generic Mike Frysinger
2009-06-14 12:01 ` [PATCH 01/17] Blackfin: use common test_bit() rather than __test_bit() Mike Frysinger
2009-06-14 12:01 ` [PATCH 02/17] Blackfin: pull in asm/io.h in ksyms for prototypes Mike Frysinger
2009-06-14 12:01 ` [PATCH 03/17] Blackfin: only build irqpanic.c when needed Mike Frysinger
2009-06-14 12:01 ` [PATCH 04/17] Blackfin: convert asm/ioctls.h to asm-generic/ioctls.h Mike Frysinger
2009-06-14 12:01 ` [PATCH 05/17] Blackfin: convert to generic checksum code Mike Frysinger
2009-06-15 11:04   ` Arnd Bergmann
2009-06-16 10:03     ` Mike Frysinger
2009-06-19  1:19     ` Mike Frysinger
2009-06-19  9:05       ` Arnd Bergmann
2009-06-19 10:42         ` Mike Frysinger
2009-06-19 12:33           ` Arnd Bergmann
2009-06-19 13:12             ` Mike Frysinger [this message]
2009-06-23 21:14               ` Arnd Bergmann
2009-06-23 21:53                 ` Mike Frysinger
2009-06-23 22:06                   ` Arnd Bergmann
2009-06-23 22:11                     ` Mike Frysinger
2009-09-19 19:08                 ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 06/17] Blackfin: convert shm/sysv/ipc to asm-generic Mike Frysinger
2009-06-14 12:01 ` [PATCH 07/17] Blackfin: convert user/elf " Mike Frysinger
2009-06-14 12:01 ` [PATCH 08/17] Blackfin: convert socket/poll " Mike Frysinger
2009-06-14 12:01 ` [PATCH 09/17] Blackfin: convert simple headers " Mike Frysinger
2009-06-14 12:01 ` [PATCH 10/17] Blackfin: convert dma/pci " Mike Frysinger
2009-06-15 11:37   ` Arnd Bergmann
2009-06-16 10:00     ` Mike Frysinger
2009-06-14 12:01 ` [PATCH 11/17] Blackfin: convert termios " Mike Frysinger
2009-06-14 12:01 ` [PATCH 12/17] Blackfin: convert locking primitives " Mike Frysinger
2009-06-14 12:01 ` [PATCH 13/17] Blackfin: convert signal/mmap " Mike Frysinger
2009-06-14 12:01 ` [PATCH 14/17] Blackfin: convert irq/process " Mike Frysinger
2009-06-14 12:01 ` [PATCH 15/17] Blackfin: convert types " Mike Frysinger
2009-06-14 12:01 ` [PATCH 16/17] Blackfin: convert page/tlb " Mike Frysinger
2009-06-14 12:01 ` [PATCH 17/17] Blackfin: convert uaccess " Mike Frysinger
2009-06-15 11:42 ` [PATCH 00/17] Blackfin arch conversion " Arnd Bergmann

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=8bd0f97a0906190612n687cdbbt1e752997acb68e49@mail.gmail.com \
    --to=vapier.adi@gmail.com \
    --cc=arnd@arndb.de \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=monstr@monstr.eu \
    --cc=uclinux-dist-devel@blackfin.uclinux.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®