From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
To: tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org
Cc: andrew.chih.howe.khor-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org,
margie.foster-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
kok.howg.ewe-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org,
joel.clark-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
yong.y.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
chripell-VaTbYqLCNhc@public.gmane.org,
qi.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH net-next-2.6 v6 04/20] can: EG20T PCH: Add Tx Flow Control
Date: Thu, 02 Dec 2010 13:12:36 -0800 (PST) [thread overview]
Message-ID: <20101202.131236.28815617.davem@davemloft.net> (raw)
In-Reply-To: <4CF47B2C.4010507-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
From: Tomoya MORINAGA <tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
Date: Tue, 30 Nov 2010 13:18:52 +0900
> Currently, there is no flow control processing.
> Thus, Add flow control processing as
> when there is no empty of tx buffer,
> netif_stop_queue is called.
> When there is empty buffer, netif_wake_queue is called.
>
> Signed-off-by: Tomoya MORINAGA <tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
When implementing functionality like this it is better to use other
existing well tested network drivers as a guide rather then trying
to be unique and clever, as you are doing here.
First of all, your netif_wake_queue() call is racy. Because another
thread can be queueing up packets, fill the queue, and execute a
stop queue right when you have made the decision to invoke
netif_wake_queue().
Second of all, checking the state of the device to determine if a
stop queue should be performed has two problems:
1) The test uses a magic constant mask, which is undocumented.
2) It causes the race you have on the wake queue side
Use pure software state to guide your actions, and let the hardware
interrupt trigger the wake queue.
Also, you don't implement this as a true ring buffer, you only
consider to stop the queue when you hit the last TX object entry. But
all the previous slots could be available.
Your head and tail pointer need to be maintained by advancing the
head pointer only during pch_xmit(), and advancing the tail pointer
only in the NAPI code as you get indications from the hardware.
Then, after the NAPI TX code advances the tail pointer, you see if
1) the queue is stopped and 2) TX space is now available. If both
are true you wake the queue.
Use a well tested and mature driver like drivers/net/tg3.c as a
guide. Search for netif_tx_{stop,wake}_queue().
next parent reply other threads:[~2010-12-02 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4CF47B2C.4010507@dsn.okisemi.com>
[not found] ` <4CF47B2C.4010507-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org>
2010-12-02 21:12 ` David Miller [this message]
2010-12-03 0:58 ` [PATCH net-next-2.6 v6 04/20] can: EG20T PCH: Add Tx Flow Control Tomoya MORINAGA
2010-11-30 4:18 Tomoya MORINAGA
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=20101202.131236.28815617.davem@davemloft.net \
--to=davem-ft/pcqaiutieiz0/mpfg9q@public.gmane.org \
--cc=andrew.chih.howe.khor-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=chripell-VaTbYqLCNhc@public.gmane.org \
--cc=joel.clark-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=kok.howg.ewe-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=margie.foster-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=qi.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
--cc=tomoya-linux-ECg8zkTtlr0C6LszWs/t0g@public.gmane.org \
--cc=wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org \
--cc=yong.y.wang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).