qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: Kevin Wolf <kwolf@redhat.com>,
	Aurelien Jarno <aurelien@aurel32.net>,
	qemu-devel <qemu-devel@nongnu.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: Re: [Qemu-devel] [PATCH] fix the return value of rtl8139_can_receive()
Date: Fri, 17 Jun 2011 09:49:43 +0800	[thread overview]
Message-ID: <4DFAB2B7.8090202@cn.fujitsu.com> (raw)
In-Reply-To: <4DF9DD77.5040401@redhat.com>

At 06/16/2011 06:39 PM, Kevin Wolf Write:
> Am 16.06.2011 10:23, schrieb Wen Congyang:
>> If rtl8139_can_receive() returns 1, it means that the nic can receive packet,
>> otherwise, it means the nic can not receive packet.
>>
>> If !s->clock_enabled or !rtl8139_receiver_enabled(s), it means that the nic
>> can not receive packet. So the return value should be 0, not 1.
>>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
>>
>> ---
>>  hw/rtl8139.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/rtl8139.c b/hw/rtl8139.c
>> index 2f8db58..9084678 100644
>> --- a/hw/rtl8139.c
>> +++ b/hw/rtl8139.c
>> @@ -810,9 +810,9 @@ static int rtl8139_can_receive(VLANClientState *nc)
>>  
>>      /* Receive (drop) packets if card is disabled.  */
>>      if (!s->clock_enabled)
>> -      return 1;
>> +      return 0;
>>      if (!rtl8139_receiver_enabled(s))
>> -      return 1;
>> +      return 0;
>>  
>>      if (rtl8139_cp_receiver_enabled(s)) {
>>          /* ??? Flow control not implemented in c+ mode.
> 
> NACK.
> 
> The old behaviour is clearly intentional. IIRC, can_receive() returning
> 0 means that the packet is kept in a queue and qemu tries to deliver it
> later. For a disabled receiver, what I would expect is that it should
> just drop the packets. This is what this code does by returning 1 in
> can_receive() and then return -1 without processing the packet in receive().

Thanks for your detailed explanation.
I know why can_receive() returns 1 now.

> 
> That said, e1000 has a check for (s->mac_reg[RCTL] & E1000_RCTL_EN) in
> can_receive. Should it be changed or is there a reason behind it? If

This check is introduced in commit 4105de67 by Anthony Liguori.
He may know the reason.

> there is, we may as well change rtl8139, but it definitely needs a
> better justification.
> 
> Kevin
> 

      parent reply	other threads:[~2011-06-17  1:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16  8:23 [Qemu-devel] [PATCH] fix the return value of rtl8139_can_receive() Wen Congyang
2011-06-16 10:39 ` Kevin Wolf
2011-06-16 12:46   ` Michael S. Tsirkin
2011-06-17  1:33     ` [Qemu-devel] [PATCH] do not send packet to nic if the packet will be dropped by nic Wen Congyang
2011-06-20  9:10       ` Kevin Wolf
2011-06-20  9:40         ` Wen Congyang
2011-06-20  9:52           ` Kevin Wolf
2011-06-20 11:13             ` Michael S. Tsirkin
2011-06-17  1:49   ` Wen Congyang [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=4DFAB2B7.8090202@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=aliguori@us.ibm.com \
    --cc=aurelien@aurel32.net \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.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).