From owner-freebsd-emulation@FreeBSD.ORG Mon May 15 19:16:23 2006 Return-Path: X-Original-To: freebsd-emulation@freebsd.org Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0732716B8D7; Mon, 15 May 2006 19:16:21 +0000 (UTC) (envelope-from nox@saturn.kn-bremen.de) Received: from gwyn.kn-bremen.de (gwyn.kn-bremen.de [212.63.36.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id B294A43D5C; Mon, 15 May 2006 19:16:02 +0000 (GMT) (envelope-from nox@saturn.kn-bremen.de) Received: from gwyn.kn-bremen.de (gwyn [127.0.0.1]) by gwyn.kn-bremen.de (8.13.4/8.13.4/Debian-3sarge1) with ESMTP id k4FJG0SH016770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 15 May 2006 21:16:00 +0200 Received: from saturn.kn-bremen.de (uucp@localhost) by gwyn.kn-bremen.de (8.13.4/8.13.4/Submit) with UUCP id k4FJG07A016768; Mon, 15 May 2006 21:16:00 +0200 Received: from saturn.kn-bremen.de (nox@localhost [127.0.0.1]) by saturn.kn-bremen.de (8.13.3/8.13.1) with ESMTP id k4FJEMFs009904; Mon, 15 May 2006 21:14:22 +0200 (CEST) (envelope-from nox@saturn.kn-bremen.de) Received: (from nox@localhost) by saturn.kn-bremen.de (8.13.3/8.13.1/Submit) id k4FJELJi009903; Mon, 15 May 2006 21:14:21 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Mon, 15 May 2006 21:14:20 +0200 To: Igor Kovalenko Message-ID: <20060515191420.GA9707@saturn.kn-bremen.de> Mail-Followup-To: Igor Kovalenko , freebsd-emulation@freebsd.org, freebsd-current@freebsd.org, Gleb Smirnoff References: <20060428221142.GA11504@saturn.kn-bremen.de> <44530C50.6040902@mail.ru> <20060430004646.GA70632@saturn.kn-bremen.de> <4458277F.4010902@mail.ru> <20060506152059.GA33481@saturn.kn-bremen.de> <445D092E.2040501@mail.ru> <20060507164230.GA63540@saturn.kn-bremen.de> <445E5C3B.405@mail.ru> <20060514211409.GA3776@saturn.kn-bremen.de> <4467CFAC.9070902@mail.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4467CFAC.9070902@mail.ru> User-Agent: Mutt/1.4.2.1i Cc: freebsd-emulation@freebsd.org, freebsd-current@freebsd.org, Gleb Smirnoff Subject: Re: playing with qemu's 8139 nic and FreeBSD (loopback mode missing? X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 May 2006 19:16:24 -0000 On Mon, May 15, 2006 at 04:47:40AM +0400, Igor Kovalenko wrote: > Juergen Lock wrote: > > On Mon, May 08, 2006 at 12:44:43AM +0400, Igor Kovalenko wrote: > >> Hi Juergen, > >> > >> Juergen Lock wrote: > >>> On Sun, May 07, 2006 at 12:38:06AM +0400, Igor Kovalenko wrote: > >>>> Hi Juergen, > >>>> > >>>> Juergen Lock wrote: > >>>>> [Cc'ing glebius@ because he did most of the recent re(4) commits, and > >>>>> -current in case possible other driver developers didn't see this thread > >>>>> in -emulation] > >>>>> > >>>>> On Wed, May 03, 2006 at 07:46:07AM +0400, Igor Kovalenko wrote: > >>>>>> Juergen Lock wrote: > >>>>>>> On Sat, Apr 29, 2006 at 10:48:48AM +0400, Igor Kovalenko wrote: > >>>>>>>> Juergen Lock wrote: > >>>>>>>>> On Fri, Apr 28, 2006 at 08:25:02PM +0400, Igor Kovalenko wrote: > >>>>>>>>>> Juergen Lock wrote: > >>>>>>>>>>> I played with > >>>>>>>>>>> qemu -monitor stdio -m 256 -cdrom 6.1-RC1-i386-disc1.iso > >>>>>>>>>>> -usb -soundhw es1370 -kernel-kqemu -net nic,model=rtl8139 > >>>>>>>>>>> -net user > >>>>>>>>>>> and got it as far as > >>>>>>>>>>> re0: diagnostic failed, failed to receive packet in loopback > >>>>>>>>>>> mode > >>>>>>>>>>> (followed by a panic :) with the (experimental) patches below. > >>>>>>>>>>> > >>>>>>>>>>> Anyone in the mood to implement loopback mode for this nic? > >>>>>>>>>>> > >>>>>>>>>>> Hmm actually... I just found the original posting in the archive, > >>>>>>>>>>> is C+ mode implemented now? If not re is probably not what I want, > >>>>>>>>>> The rtl8139 is set up with PCI rev ID 0x20 which should be enough for > >>>>>>>>>> OS driver > >>>>>>>>>> to detect C+ mode features. C+ mode is OK, tested with Linux driver. > >>>>>>>>> Cool, so I want FreeBSD's re driver. That one checks TxConfig > >>>>>>>>> tho, as changed in my patch (inside #if 0). And when changed, > >>>>>>>>> it still doesn't work as mentioned above because the driver expects > >>>>>>>>> loopback mode to be working. > >>>>>>>>>>> but the rl driver that it attaches without that #if 0'd (now) hunk > >>>>>>>>>>> below doesnt seem to be able to get data thru either and I get > >>>>>>>>>>> rl0: watchdog timeout > >>>>>>>>>>> in dmesg, which usually means the driver doesnt receive interrupts. > >>>>>>>>>>> > >>>>>>>>>>> What the heck, I'll append a log of a run just doing in > >>>>>>>>>>> fixit->cdrom: > >>>>>>>>>>> ifconfig rl0 10.0.2.15 > >>>>>>>>>>> and then exiting (which is enough to trigger the watchdog timeout...) > >>>>>>>>>>> > >>>>>>>>>> I'm too lasy to test with fresh freebsd installation :) > >>>>>>>>> No need to install FreeBSD, you can get away by just using > >>>>>>>>> fixit mode of an install iso, i.e. disc1. (which actually is > >>>>>>>>> what I did above. :) > >>>>>>>>> > >>>>>>>>> You can look at 6.1RC's re driver here: > >>>>>>>>> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/re/if_re.c?annotate=1.46.2.14 > >>>>>>>>> which includes: > >>>>>>>>> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/pci/if_rlreg.h?annotate=1.51.2.3 > >>>>>>>>> > >>>>>>>>> And 6.1RC disc1 iso is e.g. here: > >>>>>>>>> ftp://ftp.ru.freebsd.org:/pub/FreeBSD/ISO-IMAGES-i386/6.1/6.1-RC1-i386-disc1.iso > >>>>>>>>> > >>>>>>>>> > >>>>>>>> Thanks, that iso pointer made it. > >>>>>>>> > >>>>>>> :) > >>>>>>> > >>>>>>>> Please try the following on top of your patch, at least ping should now > >>>>>>>> work: > >>>>>>> Thanks, that seems to get the rl driver going. Now to fix C+ mode > >>>>>>> (re driver) change the #if 0 in my patch to #if 1... > >>>>>>> > >>>>>>> > >>>>>> I believe freebsd re driver is somewhat broken, e.g. it does not follow > >>>>>> documented > >>>>>> procedure to detect hardware features (e.g. 8139 c+ mode) > >>>>> Hmm, a bit of googling didn't reveal docs about this, do you have > >>>>> a pointer? (I only found the data sheet at > >>>>> http://people.freebsd.org/~wpaul/RealTek/spec-8139cp(150).pdf > >>>>> which doesnt seem to mention detecting c+ hardware specifically) > >>>> Well, I might have misread some docs; please do not consider this as an > >>>> assault :) > >>>> I remember PCI rev id >= 0x20 is C+ mode for realtek 8139. > >>> I don't. It may well be the doc you saw this in just is no longer > >>> online, or I didn't came up with the right search terms... > >>>>>> and in tries to use 8169 > >>>>>> registers (e.g. 0xda) on 8139 hardware etc. > >>>>> Oh, then it must have mis-detected the nic as a 8169 because > >>>>> the code in question reads: > >>>>> > >>>>> if (sc->rl_type == RL_8169) > >>>>> CSR_WRITE_2(sc, RL_MAXRXPKTLEN, 16383); > >>> And with your patch i get > >>> RTL8139: not implemented write(b) addr=0xda val=0x00 > >>> but that can't be this line anyway because it seems to be a byte access... > >>> Any of the re(4) experts have an idea where this comes from? > >>> (log generated by defining DEBUG_RTL8139 in the patched hw/rtl8139.c) > >>> > >> I see the re driver actually is doing 2 byte write at RL_TXSTART so the second > >> byte goes to RL_MAXRXPKTLEN. Comment in if_rlreg.h says RL_TXSTART is 8bit > >> so this is a bug in if_re.c line 2063 > >> > >> This is not affecting qemu's card emulation (the extra byte write is ignored) > >> so I think the problem is somewhere else. > > > > I finally got around to playing with this a bit again, the following > > patch gets ping and small fetch (http) going but is not enough for scp: > > > > Index: hw/rtl8139.c > > @@ -1008,15 +1038,22 @@ > > val = cpu_to_le32(rxdw1); > > cpu_physical_memory_write(cplus_rx_ring_desc+4, (uint8_t *)&val, 4); > > > > - /* seek to next Rx descriptor */ > > - if (rxdw0 & CP_RX_EOR) > > - { > > - s->currCPlusRxDesc = 0; > > - } > > - else > > - { > > - ++s->currCPlusRxDesc; > > - } > > +#ifdef DEBUG_RTL8139 > > + printf("RTL8139: +++ written C+ mode RX descriptor %d %08x %08x %08x %08x\n", > > + descriptor, > > + rxdw0, rxdw1, rxbufLO, rxbufHI); > > +#endif > > + /* seek to next Rx descriptor unless in loopback mode */ > > + if (!(TxLoopBack == (s->TxConfig & TxLoopBack))) { > > + if (rxdw0 & CP_RX_EOR) > > + { > > + s->currCPlusRxDesc = 0; > > + } > > + else > > + { > > + ++s->currCPlusRxDesc; > > + } > > + } > > > > #if defined(DEBUG_RTL8139) > > printf("RTL8139: done C+ Rx mode ----------------\n"); > > > > > > That is strange; I must be missing docs pointer about loopback mode > operation again. What makes you believe that RX descriptor should not > advance in loopback mode? Oh, only that re(4) expects it to be that way. :) It may also be that it gets reset by the turning off of loopback mode or by something else at that time, I dont know...