From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCS4y-00056Q-98 for qemu-devel@nongnu.org; Fri, 14 Sep 2012 05:20:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCS4x-0003tb-4x for qemu-devel@nongnu.org; Fri, 14 Sep 2012 05:20:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48802) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCS4w-0003tH-SN for qemu-devel@nongnu.org; Fri, 14 Sep 2012 05:20:51 -0400 Message-ID: <5052F6D8.2050402@redhat.com> Date: Fri, 14 Sep 2012 17:20:24 +0800 From: Amos Kong MIME-Version: 1.0 References: <504DA1A9.2000908@redhat.com> <1347588966-20350-1-git-send-email-akong@redhat.com> <5052EC74.7000803@redhat.com> In-Reply-To: <5052EC74.7000803@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] rtl8139: implement 8139cp link status List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: jasowang@redhat.com, mst@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org On 14/09/12 16:36, Paolo Bonzini wrote: > Il 14/09/2012 04:16, Amos Kong ha scritto: >> + /* The LinkDown bit of MediaStatus is inverse with link status */ >> + ret = 0xd0 | (s->nic->nc.link_down ? MSR_LinkDown : 0); >> DPRINTF("MediaStatus read 0x%x\n", ret); >> break; >> >> @@ -3453,12 +3466,27 @@ static void pci_rtl8139_uninit(PCIDevice *dev) >> qemu_del_net_client(&s->nic->nc); >> } >> >> +static void rtl8139_set_link_status(NetClientState *nc) >> +{ >> + RTL8139State *s = DO_UPCAST(NICState, nc, nc)->opaque; >> + >> + if (nc->link_down) { >> + s->BasicModeStatus &= ~0x0004; >> + } else { >> + s->BasicModeStatus |= 0x0004; >> + } >> + >> + s->IntrStatus |= RxUnderrun; >> + rtl8139_update_irq(s); >> +} >> + > > Actually, this is worse than v2 because then one bit is migrated and the > other is not. > I think v2 is correct and, on top of it, you have to check in post_load > whether nc->link_down matches the loaded BMSR value. If not, you need > to either set the link status in NetClientState, or generate an > RxUnderrun interrupt. If correct link_down in rtl8139_post_load(), both v2 and v3 will work. s->nic->nc.link_down = (s->BasicModeStatus & 0x04) == 0; s->BasicModeStatus is really migrated, s->nic->nc.link_down is inferred. so I will continually work on v2. > An alternative is to add a get_link_status callback and call it after > migration for all NIC NetClientStates. > > Paolo Thanks. -- Amos.