Subject: Updated MTD driver
To: None <tech-net@netbsd.org>
From: Peter Bex <Peter.Bex@student.kun.nl>
List: tech-net
Date: 06/26/2003 15:42:55
--Pd0ReVV5GZGQvF3a
Content-Type: multipart/mixed; boundary="6c2NcOVqGQ03X4Wi"
Content-Disposition: inline
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello all,
After a long while, I finally found some time to look into my network
driver's problems.
My question is: What should I do when sending packets which are too large?
Is there any way to know what the maximum size is of a packet the kernel wi=
ll
emit? I didn't know it at the time I wrote the code, and I still don't
know it. :(
There's probably something I don't quite understand in the networking code =
in
general, since other network drivers seem to simply ignore the size, as if
they trust it'll always be correct. That would cause a memory overrun if the
size is not correct, so there's probably something I've missed.
At the moment, the driver spits out a debugging warning and ignores the pac=
ket.
(see the XXX FIXME in dev/ic/mtd803.c)
Attached to this e-mail are patches for the files of the driver,
which take a larger transmit buffer. It's the largest possible buffer for
the MTD. Increasing the receiver buffer size raises the receive buffer
unavailable interrupt, so I didn't change its value.
The longer transmit buffer makes sure there are no(?) debug messages on the
console any more, but I have a feeling that is just coincidence, unless
there is some general agreement that the maximum size of a packet will never
exceed 2047 bytes...
The receive buffer stuff really scares me, since it SHOULD be possible to
use a buffer of size 1024. At least, the registers support it.
Can someone please cvs commit this new version? Thank you.
I would like to clean up the code before it gets integrated in NetBSD 2.0.
The debugging messages are quite annoying, and they are numerous, something
you would not want in a release. (although with the patch they seem to be
gone)
Please CC me in any replies as I'm not on the tech-net list.
Regards,
Peter
--=20
http://www.student.kun.nl/peter.bex
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Description: mtd803.c.diff
Content-Disposition: attachment; filename="mtd803.c.diff"
--- mtd803.c.orig 2003-06-26 15:24:00.000000000 +0200
+++ mtd803.c 2003-06-26 15:25:34.000000000 +0200
@@ -461,8 +461,8 @@
continue;
} else if (tlen > MTD_TXBUF_SIZE) {
/* XXX FIXME: No idea what to do here. */
- printf("%s: packet too large!\n",
- sc->dev.dv_xname);
+ printf("%s: packet too large! Packet size: %i\n",
+ sc->dev.dv_xname, tlen);
MFREE(m, n);
continue;
}
--6c2NcOVqGQ03X4Wi
Content-Type: text/plain; charset=us-ascii
Content-Description: mtd803var.h.diff
Content-Disposition: attachment; filename="mtd803var.h.diff"
47c47
< /* Number of Tx and Rx descriptors */
---
> /* Number of Tx and Rx descriptors. Quite arbitrarily chosen. */
50c50
< /* Tx and Rx buffer size */
---
> /* Tx and Rx buffer size. The Rx buffer size must be a multiple of 4. */
52c52
< #define MTD_TXBUF_SIZE 768
---
> #define MTD_TXBUF_SIZE 2047
--6c2NcOVqGQ03X4Wi--
--Pd0ReVV5GZGQvF3a
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (NetBSD)
iD8DBQE++vheLg33BXzVMqsRAuhXAKCOQ7b/EA1MS5u0vPtQPSHq9kA6ewCdFE9S
CJ8SIRKVo6tCXLU4gOHWaFs=
=6LHn
-----END PGP SIGNATURE-----
--Pd0ReVV5GZGQvF3a--