public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: "Jürgen Lambrecht" <J.Lambrecht@televic.com>
To: I-Yanaslov <yanaslov_iv@ic-bresler.ru>
Cc: ecos-discuss@ecos.sourceware.org, Andrew Lunn <andrew@lunn.ch>
Subject: [ECOS] `
Date: Wed, 11 Jun 2008 10:12:00 -0000	[thread overview]
Message-ID: <484FA4B1.20002@televic.com> (raw)
In-Reply-To: <00e701c8cb8c$65862810$4664a8c0@icbresler>

I-Yanaslov wrote:
>
> ----- Original Message ----- From: "Jürgen Lambrecht" 
> <J.Lambrecht@televic.com>
> To: <ecos-discuss@ecos.sourceware.org>
> Cc: "Andrew Lunn" <andrew@lunn.ch>; "I-Yanaslov" 
> <yanaslov_iv@ic-bresler.ru>
> Sent: Tuesday, June 10, 2008 8:11 PM
> Subject: Re: [ECOS] "packets eaten" with AT91 EMAC Ethernet driver
>
>
>> Lambrecht Jürgen wrote:
>
>> Indeed, that was the problem:
>> Wrong code in at91_eth_deliver():
>>
>>   if (tsr&AT91_EMAC_TSR_COMP) //5
>>   {
>>      at91_reset_tbd(priv);
>>      _eth_drv_tx_done(sc,priv->curr_tx_key,0);
>>      priv->tx_busy = false;
>>   }
>>
>> Correct code:
>>   {
>>      at91_reset_tbd(priv, b_reset_tbd_idx);
>>      priv->tx_busy = false;
>>      _eth_drv_tx_done(sc,priv->curr_tx_key,0);
>>   }
>>
>> If the low-level driver is available (can_send() returns not zero) 
>> then the first packet is sent.
>> If the low-level driver is not available it stops here. It is 
>> supposed that the low-level driver will inform then the middleware 
>> when it is ready by calling tx_done.
>> eth_drv_tx_done on its turn calls eth_drv_send() which then checks 
>> again can_send()
>>
>> The AT91 driver first called tx_done, calling send calling can_send 
>> which returns 0 of course.
>> And afterwards - too late - busy is set to true, so that can_send can 
>> return 1...
>
> "priv->tx_busy = false;" is not consumes many time.
indeed
> So, ISR is better place to do it.
> Than, TX driver becomes to ready (can_send() returns 1 ) just at 
> moment whan a HW becomes to ready, even if DSR and __eth_drv_tx_done() 
> is still running.
>
Yes, that could be a good idea.
I can only think of 1 problem:

The moment you set "priv->tx_busy = false;", packets can be sent. And if 
the TCP/IP stack has new data to send (e.g. because of a new RX), it 
will call send(), and then finally the transmit status bits in the TSR 
register can be overwritten before at91_eth_deliver() has read out the 
TSR register for the previous packet.
This should not be possible, if at91_eth_deliver() runs in DSR context, 
because a DSR will always run before "normal" functions.
But I don't think at91_eth_deliver() is called under DSR context.

This is the call stack:
The DSR is /io/eth/current/src/net/eth_drv.c::eth_drv_dsr() ->
/net/bsd_tcpip/current/src/ecos/timeout.c::ecos_synch_eth_drv_dsr() 
{cyg_flag_setbits( &alarm_flag, 2 ); }
This flags the alarm-flag of the alarm_thread() (cyg_flag_wait(..)) ->
/io/eth/current/src/net/eth_drv_run_deliveries() -> at91_eth_deliver()

When the alarm-flag is flagged by the DSR function, the scheduler wakes 
up the alarm thread, but is this alarm_thread() still run under DSR 
context???

I don't think so.
deliver() is meant to run under thread context and not DSR context, 
because all the copying and buffer handling takes too long for DSR 
context (?).

Kind regards,
Jürgen

> Ivan.
>
>
>



-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

  reply	other threads:[~2008-06-11 10:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-09 20:55 [ECOS] "packets eaten" with AT91 EMAC Ethernet driver Lambrecht Jürgen
2008-06-10 16:11 ` Jürgen Lambrecht
2008-06-11  6:30   ` I-Yanaslov
2008-06-11 10:12     ` Jürgen Lambrecht [this message]
  -- strict thread matches above, loose matches on Subject: below --
2005-01-16  5:40 [ECOS] ÄãÏëÔÚÊé³ÇÅÔÓиöÕÐÉúµã»ò°ìÊ´¦Â𣿠any
2001-06-12 21:51 [ECOS] Piteir
2002-08-21  9:31 ` [ECOS] Robert Cragie

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=484FA4B1.20002@televic.com \
    --to=j.lambrecht@televic.com \
    --cc=andrew@lunn.ch \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=yanaslov_iv@ic-bresler.ru \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).