public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Nick Garnett <nickg@ecoscentric.com>
To: Xiaochen Zhou <zhouxiaochen@h3c.com>
Cc: ecos-discuss@sources.redhat.com
Subject: Re: [ECOS] eth_drv_send() called recursively
Date: Thu, 24 May 2007 12:30:00 -0000	[thread overview]
Message-ID: <m3hcq2mu9v.fsf@xl5.calivar.com> (raw)
In-Reply-To: <009501c79dde$685e4ea0$ae7aa50a@h3c.huawei3com.com>

Xiaochen Zhou <zhouxiaochen@h3c.com> writes:

> Hi,everyone:
> 
> Here is ethernet packet sending flow in our ecos application:
> 
> 1. eth_drv_send() call my_eth_driver_send()
> 2. my_eth_driver_send() call eth_drv_tx_done()
> 3. eth_drv_tx_done() call eth_drv_send()
> 
> eth_drv_send() and eth_drv_tx_done() are implemented in
> io/eth/current/src/net/eth_drv.c
> 
> eth_drv_tx_done(struct eth_drv_sc *sc, CYG_ADDRESS key, int status)
> {
>     ....
>     eth_drv_send(ifp);
>     ....
> 
> eth_drv_send(struct ifnet *ifp)
> {
>     ....
>     while ((sc->funs->can_send)(sc) > 0) {
>         IF_DEQUEUE(&ifp->if_snd, m0);
>         if (m0 == 0) {
>             break;
>         }
>     ....
> }
> 
> If sending queue has many mbufs (we using queue for QOS application),
> sending thread will call eth_drv_send() recursively, the stack of packet
> sending thread will overflow.
> 
> Can anyone tell me why call eth_drv_send() in eth_drv_tx_done()? In
> eth_drv_send(), there are a loop to call IF_DEQUEUE(), so I think it is
> useless and harmful. Can I delete "eth_drv_send(ifp)" line in
> eth_drv_tx_done()?

No!

In general eth_drv_tx_done() is not called from the driver's send
routine, it is usually called from the deliver/poll routine once the
packet has actually been transmitted. Usually in response to an
interrupt.

The only situation in which eth_drv_tx_done() may be called from the
send routine is if you have copied the packet out to an internal
buffer, in the driver or hardware. In this case the can_send routine
will fend off susequent send attempts until the packet is sent and a
buffer is available.

So I suspect that either your driver is calling eth_drv_tx_done() in
the wrong place, or your can_send routine is not working correctly.

Whatever the problem, deleting lines from generic code that has been
working corretly for many years is not the correct solution.


-- 
Nick Garnett                                     eCos Kernel Architect
eCosCentric Limited     http://www.eCosCentric.com/   The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.    Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.


-- 
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:[~2007-05-24  9:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-24  9:43 Xiaochen Zhou
2007-05-24 12:30 ` Nick Garnett [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=m3hcq2mu9v.fsf@xl5.calivar.com \
    --to=nickg@ecoscentric.com \
    --cc=ecos-discuss@sources.redhat.com \
    --cc=zhouxiaochen@h3c.com \
    /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).