public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ben Warren <biggerbadderben@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] smc911x driver frame alignment patch
Date: Sun, 25 Apr 2010 21:53:09 -0700	[thread overview]
Message-ID: <4BD51C35.4080009@gmail.com> (raw)
In-Reply-To: <4BD132C7.9060604@niistt.ru>

  Valentin,
On 4/22/2010 10:40 PM, Valentin Yakovenkov wrote:
> SMSC911x chips have alignment function to allow frame payload data
> (which comes after 14-bytes ethernet header) to be aligned at some
> boundary when reading it from fifo (usually - 4 bytes boundary).
> This is done by inserting fake zeros bytes BEFORE actual frame data when
> reading from SMSC's fifo.
> This function controlled by RX_CFG register. There are bits that
> represents amount of fake bytes to be inserted.
>
> Linux uses alignment of 4 bytes. Ethernet frame header is 14 bytes long,
> so we need to add 2 fake bytes to get payload data aligned at 4-bytes
> boundary.
> Linux driver does this by adding IP_ALIGNMENT constant (defined at
> skb.h) when calculating fifo data length. All network subsystem of Linux
> uses this constant too when calculating different offsets.
>
> But u-boot does not use any packet data alignment, so we don't need to
> add anything when calculating fifo data length.
> Moreover, driver zeros the RX_CFG register just one line up, so chip
> does not insert any fake data at the beginig. So calculated data length
> is always bigger by 1 word.
>
> It seems that at almost every packet read we get an underflow condition
> at fifo and possible corruption of data. Especially at continuous
> transfers, such as tftp.
>
> Just after removing this magic addition, I've got tftp transfer speed as
> it aught to be at 100Mbps. It was really slow before.
>
> It seems that fifo underflow occurs only when using byte packing on
> 32-bit blackfin bus (may be because of very small delay between reads).
>
>
>
> Signed-off-by: Valentin Yakovenkov<yakovenkov@niistt.ru>
> diff -r 7dc8ff189175 a/drivers/net/smc911x.c
> --- a/drivers/net/smc911x.c	Mon Mar 29 11:08:55 2010 +0400
> +++ b/drivers/net/smc911x.c	Mon Apr 19 10:46:02 2010 +0400
> @@ -220,7 +220,7 @@
>
>   		smc911x_reg_write(dev, RX_CFG, 0);
>
> -		tmplen = (pktlen + 2+ 3) / 4;
> +		tmplen = (pktlen + 3) / 4;
>   		while (tmplen--)
>   			*data++ = pkt_data_pull(dev, RX_DATA_FIFO);
>
> --
>    WBR, Valentin
>    CJSC "NII STT", Russia, Smolensk
>    http://www.niistt.ru
>
>    
Applied to net repo.

thanks,
Ben

      parent reply	other threads:[~2010-04-26  4:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23  5:40 [U-Boot] [PATCH v2] smc911x driver frame alignment patch Valentin Yakovenkov
2010-04-23 15:11 ` Mike Frysinger
2010-04-23 16:48   ` Valentin Yakovenkov
2010-04-23 16:53     ` Mike Frysinger
2010-04-26  4:53 ` Ben Warren [this message]

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=4BD51C35.4080009@gmail.com \
    --to=biggerbadderben@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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