From patchwork Thu Oct 31 00:21:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jacek burghardt X-Patchwork-Id: 287367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C3EB72C03BB for ; Thu, 31 Oct 2013 11:22:02 +1100 (EST) Received: from localhost ([::1]:54982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbg1Q-0002Ry-7G for incoming@patchwork.ozlabs.org; Wed, 30 Oct 2013 20:22:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbg15-0002Rs-1r for qemu-devel@nongnu.org; Wed, 30 Oct 2013 20:21:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vbg13-0005NC-NE for qemu-devel@nongnu.org; Wed, 30 Oct 2013 20:21:38 -0400 Received: from mail-la0-x22d.google.com ([2a00:1450:4010:c03::22d]:36487) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vbg13-0005MP-Ad; Wed, 30 Oct 2013 20:21:37 -0400 Received: by mail-la0-f45.google.com with SMTP id hp15so1703542lab.18 for ; Wed, 30 Oct 2013 17:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=pOTgc7WuJyit1VV6CRy1GOoOWcHGZeo+ePLQTQ/JQh0=; b=erwAH7O89RNVWpTCHMhPYfgMCqyQfw5jGQqh1UEsLI9aqbwI43I1E4knXY5Uq16QcX y83x87SbYUhLho85Gy2em95SxsODbLeHQ2x6/cuUpU0GNzgcnqbsjlNK/5cRSFvDXMTQ Iy5QrRXxss7zXjCJMv6/LdV2DZGSPng98NWOtsZx3PhCEiOPq6tR7s2ol+R/h4+8YdvN pGEsatSv078ifkeJiCpGtXzkHAYM+7/c6k9Nvc0DuSkFz4ai32mgkBsaD8V4/PS75Kp1 GWb+P9Xjbh5kp3qDBLwbTGJ6OvH6bQ9F7ULKMySKb1HRh6CTd02TQYS0nZTCNP/sziet DEaw== MIME-Version: 1.0 X-Received: by 10.112.125.33 with SMTP id mn1mr707816lbb.8.1383178895905; Wed, 30 Oct 2013 17:21:35 -0700 (PDT) Received: by 10.112.182.34 with HTTP; Wed, 30 Oct 2013 17:21:35 -0700 (PDT) In-Reply-To: <52719D80.3030905@redhat.com> References: <526A7E71.7090203@redhat.com> <52719D80.3030905@redhat.com> Date: Wed, 30 Oct 2013 18:21:35 -0600 Message-ID: From: jacek burghardt To: Paolo Bonzini X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22d Cc: qemu-devel@nongnu.org, qemu-discuss Subject: Re: [Qemu-devel] e1000 patch for osx X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org I am in process of recompiling qemu right now I came up with this patch is this correct } @@ -409,6 +417,8 @@ { /* RST is self clearing */ s->mac_reg[CTRL] = val & ~E1000_CTRL_RST; + if (val & E1000_CTRL_RST) + set_ics(s, 0, E1000_ICR_LSC); } static void @@ -446,7 +456,15 @@ if (addr < NPHYWRITEOPS && phyreg_writeops[addr]) { phyreg_writeops[addr](s, index, data); } - s->phy_reg[addr] = data; + switch (addr) { + case PHY_CTRL: + s->phy_reg[addr] = data & 0x7eff; + if (s->phy_reg[addr] != data) + set_ics(s, 0, E1000_ICR_LSC); + break; + default: + s->phy_reg[addr] = data; + } } } s->mac_reg[MDIC] = val | E1000_MDIC_READY; @@ -1163,8 +1181,13 @@ static void set_ims(E1000State *s, int index, uint32_t val) { + uint32_t old_val = s->mac_reg[IMS]; s->mac_reg[IMS] |= val; - set_ics(s, 0, 0); + if ((val & E1000_ICR_LSC) && old_val == 0) { + set_ics(s, 0, E1000_ICR_LSC); /* inject Link Status for uncooperative Darwin driver */ + } else { + set_ics(s, 0, 0); + } } #define getreg(x) [x] = mac_readreg @@ -1192,7 +1215,7 @@ static void (*macreg_writeops[])(E1000State *, int, uint32_t) = { putreg(PBA), putreg(EERD), putreg(SWSM), putreg(WUFC), putreg(TDBAL), putreg(TDBAH), putreg(TXDCTL), putreg(RDBAH), - putreg(RDBAL), putreg(LEDCTL), putreg(VET), + putreg(RDBAL), putreg(LEDCTL), putreg(VET), putreg(MANC), [TDLEN] = set_dlen, [RDLEN] = set_dlen, [TCTL] = set_tctl, [TDT] = set_tctl, [MDIC] = set_mdic, [ICS] = set_ics, [TDH] = set_16bit, [RDH] = set_16bit, [RDT] = set_rdt, On Wed, Oct 30, 2013 at 6:00 PM, Paolo Bonzini wrote: > Il 31/10/2013 00:54, jacek burghardt ha scritto: > > I wonder if anyone can post reworked patch to latest qemu > > That's what I did 5 hours ago, though what I did was actually to look at > the bits affected by the patch and reimplement them based on the e1000 > hardware spec. Can you test the second patch I posted and see if it > works for you? > > Paolo > diff -Naur qemu/hw/net/e1000.c qemu-a/hw/net/e1000.c --- qemu/hw/net/e1000.c 2013-10-27 15:36:05.496526538 -0600 +++ qemu-a/hw/net/e1000.c 2013-10-30 18:09:03.101711694 -0600 @@ -203,6 +203,12 @@ DBGOUT(PHY, "Start link auto negotiation\n"); timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } + + if (val & 0x8000) { + val &= 0x7fff; + set_ics(s, 0, E1000_ICR_LSC); + } + s->phy_reg[PHY_CTRL] = val; } static void @@ -390,6 +396,8 @@ d->rxbuf_min_shift = 1; memset(&d->tx, 0, sizeof d->tx); + d->mac_reg[RA+0] = (macaddr[3] << 24) | (macaddr[2] << 16) | (macaddr[1] << 8) | macaddr[0]; + d->mac_reg[RA+1] = E1000_RAH_AV | (macaddr[5] << 8) | macaddr[4]; if (qemu_get_queue(d->nic)->link_down) { e1000_link_down(d);