Received: from [140.186.70.92] (port=45220 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Puqqv-0004ED-3w for qemu-devel@nongnu.org; Wed, 02 Mar 2011 13:32:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Puqnf-0005lz-AO for qemu-devel@nongnu.org; Wed, 02 Mar 2011 13:29:28 -0500 Received: from chello084112167138.7.11.vie.surfer.at ([84.112.167.138]:54839 helo=wiesinger.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Puqne-0005l9-Qz for qemu-devel@nongnu.org; Wed, 02 Mar 2011 13:29:27 -0500 Date: Wed, 2 Mar 2011 19:28:10 +0100 (CET) From: Gerhard Wiesinger Subject: Re: [Qemu-devel] Re: [PATCH] moving eeprom initialization In-Reply-To: Message-ID: References: <1299072986-11496-1-git-send-email-wdauchy@gmail.com> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-1463811584-591706267-1299090491=:1898" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: William Dauchy Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463811584-591706267-1299090491=:1898 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by wiesinger.com id p22ISCt9002826 Hello, Your patch should be based on fixes for correct EEPROM initialization,=20 see for details:=20 http://www.mail-archive.com/qemu-devel@nongnu.org/msg56414.html Ciao, Gerhard -- http://www.wiesinger.com/ On Wed, 2 Mar 2011, William Dauchy wrote: > On Wed, Mar 2, 2011 at 2:36 PM, William Dauchy wrot= e: >> The initialization should not be only on reset but also when initializ= ing >> the device. >> It resolves a bug when hot plugging a pci network device: the mac addr= ess >> was always null. >> --- >> =A0hw/pcnet.c =A0 | =A0 27 ++++++++++++++------------- >> =A0hw/rtl8139.c | =A0 24 ++++++++++++------------ >> =A02 files changed, 26 insertions(+), 25 deletions(-) >> >> diff --git a/hw/pcnet.c b/hw/pcnet.c >> index db52dc5..4e30e9c 100644 >> --- a/hw/pcnet.c >> +++ b/hw/pcnet.c >> @@ -1557,19 +1557,6 @@ uint32_t pcnet_bcr_readw(PCNetState *s, uint32_= t rap) >> =A0void pcnet_h_reset(void *opaque) >> =A0{ >> =A0 =A0 PCNetState *s =3D opaque; >> - =A0 =A0int i; >> - =A0 =A0uint16_t checksum; >> - >> - =A0 =A0/* Initialize the PROM */ >> - >> - =A0 =A0memcpy(s->prom, s->conf.macaddr.a, 6); >> - =A0 =A0s->prom[12] =3D s->prom[13] =3D 0x00; >> - =A0 =A0s->prom[14] =3D s->prom[15] =3D 0x57; >> - >> - =A0 =A0for (i =3D 0,checksum =3D 0; i < 16; i++) >> - =A0 =A0 =A0 =A0checksum +=3D s->prom[i]; >> - =A0 =A0*(uint16_t *)&s->prom[12] =3D cpu_to_le16(checksum); >> - >> >> =A0 =A0 s->bcr[BCR_MSRDA] =3D 0x0005; >> =A0 =A0 s->bcr[BCR_MSWRA] =3D 0x0005; >> @@ -1736,6 +1723,9 @@ void pcnet_common_cleanup(PCNetState *d) >> >> =A0int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInf= o *info) >> =A0{ >> + =A0 =A0int i; >> + =A0 =A0uint16_t checksum; >> + >> =A0 =A0 s->poll_timer =3D qemu_new_timer(vm_clock, pcnet_poll_timer, s= ); >> >> =A0 =A0 qemu_macaddr_default_if_unset(&s->conf.macaddr); >> @@ -1744,5 +1734,16 @@ int pcnet_common_init(DeviceState *dev, PCNetSt= ate *s, NetClientInfo *info) >> >> =A0 =A0 add_boot_device_path(s->conf.bootindex, dev, "/ethernet-phy@0"= ); >> >> + =A0 =A0/* Initialize the PROM */ >> + >> + =A0 =A0memcpy(s->prom, s->conf.macaddr.a, 6); >> + =A0 =A0s->prom[12] =3D s->prom[13] =3D 0x00; >> + =A0 =A0s->prom[14] =3D s->prom[15] =3D 0x57; >> + >> + =A0 =A0for (i =3D 0, checksum =3D 0; i < 16; i++) { >> + =A0 =A0 =A0 =A0checksum +=3D s->prom[i]; >> + =A0 =A0} >> + =A0 =A0*(uint16_t *)&s->prom[12] =3D cpu_to_le16(checksum); >> + >> =A0 =A0 return 0; >> =A0} >> diff --git a/hw/rtl8139.c b/hw/rtl8139.c >> index a22530c..8356d5a 100644 >> --- a/hw/rtl8139.c >> +++ b/hw/rtl8139.c >> @@ -1189,18 +1189,6 @@ static void rtl8139_reset(DeviceState *d) >> >> =A0 =A0 rtl8139_update_irq(s); >> >> - =A0 =A0/* prepare eeprom */ >> - =A0 =A0s->eeprom.contents[0] =3D 0x8129; >> -#if 1 >> - =A0 =A0// PCI vendor and device ID should be mirrored here >> - =A0 =A0s->eeprom.contents[1] =3D PCI_VENDOR_ID_REALTEK; >> - =A0 =A0s->eeprom.contents[2] =3D PCI_DEVICE_ID_REALTEK_8139; >> -#endif >> - >> - =A0 =A0s->eeprom.contents[7] =3D s->conf.macaddr.a[0] | s->conf.maca= ddr.a[1] << 8; >> - =A0 =A0s->eeprom.contents[8] =3D s->conf.macaddr.a[2] | s->conf.maca= ddr.a[3] << 8; >> - =A0 =A0s->eeprom.contents[9] =3D s->conf.macaddr.a[4] | s->conf.maca= ddr.a[5] << 8; >> - >> =A0 =A0 /* mark all status registers as owned by host */ >> =A0 =A0 for (i =3D 0; i < 4; ++i) >> =A0 =A0 { >> @@ -3392,6 +3380,18 @@ static int pci_rtl8139_init(PCIDevice *dev) >> >> =A0 =A0 qemu_macaddr_default_if_unset(&s->conf.macaddr); >> >> + =A0 =A0/* prepare eeprom */ >> + =A0 =A0s->eeprom.contents[0] =3D 0x8129; >> +#if 1 >> + =A0 =A0/* PCI vendor and device ID should be mirrored here */ >> + =A0 =A0s->eeprom.contents[1] =3D PCI_VENDOR_ID_REALTEK; >> + =A0 =A0s->eeprom.contents[2] =3D PCI_DEVICE_ID_REALTEK_8139; >> +#endif >> + >> + =A0 =A0s->eeprom.contents[7] =3D s->conf.macaddr.a[0] | s->conf.maca= ddr.a[1] << 8; >> + =A0 =A0s->eeprom.contents[8] =3D s->conf.macaddr.a[2] | s->conf.maca= ddr.a[3] << 8; >> + =A0 =A0s->eeprom.contents[9] =3D s->conf.macaddr.a[4] | s->conf.maca= ddr.a[5] << 8; >> + >> =A0 =A0 s->nic =3D qemu_new_nic(&net_rtl8139_info, &s->conf, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev->qdev.info->na= me, dev->qdev.id, s); >> =A0 =A0 qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a); >> -- >> William > > hm I just noticed your correction here > http://lists.gnu.org/archive/html/qemu-devel/2011-02/msg03232.html ; > sorry > Anyway, I tested my version and it works fine. > > Regards, > > --=20 > William > > > ---1463811584-591706267-1299090491=:1898--