From owner-freebsd-current@FreeBSD.ORG Tue Jun 9 21:12:13 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8DC7D106568D; Tue, 9 Jun 2009 21:12:13 +0000 (UTC) (envelope-from jfvogel@gmail.com) Received: from mail-pz0-f195.google.com (mail-pz0-f195.google.com [209.85.222.195]) by mx1.freebsd.org (Postfix) with ESMTP id 588CC8FC1C; Tue, 9 Jun 2009 21:12:13 +0000 (UTC) (envelope-from jfvogel@gmail.com) Received: by pzk33 with SMTP id 33so287780pzk.3 for ; Tue, 09 Jun 2009 14:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=7JGlyLz67+Gmu3kCRowqfnvhyF8JwulNQGFiLw8Tn9g=; b=jmMidWPo6kVCURtpxktB4+kKzNjDkOAJC/JSrnpSsDj2GyWWCXvMTamhjmATZoZY4X VHJDE44uHfiHxfcOy5gv+Y6FPMqToNQypQfVOQLMSGkubcAsyXk6KtVqUhUY0vqj7aj/ pFTFFu0EGDQS/8mrc2WJKO1Yi8zQG2o9KjrzM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=Hz5J2XdOER5RrAx2VhCJ4Gyq1+fDOwnhln9u3Wn+/Sk4Uukr1rccwXEYY7yIdJYEdI EqZz/wlefhEtqALZT5ovt8CO40NwuZOBtI951MJwgC/bmE8jt5YtoKcwK5UHY6d8AGDZ nfg+A/x+I9PzLlBuUvmRVSBitgX0YwfCCxkvo= MIME-Version: 1.0 Received: by 10.142.234.16 with SMTP id g16mr209891wfh.107.1244581932884; Tue, 09 Jun 2009 14:12:12 -0700 (PDT) In-Reply-To: <20090609195141.GA4982@triton.kn-bremen.de> References: <20090606162235.GA49444@triton.kn-bremen.de> <2a41acea0906091104q17aeb174l8a34bf7464a80509@mail.gmail.com> <20090609195141.GA4982@triton.kn-bremen.de> Date: Tue, 9 Jun 2009 14:12:12 -0700 Message-ID: <2a41acea0906091412k4fc58f4dt2c4ebbbb6dbd46dd@mail.gmail.com> From: Jack Vogel To: Juergen Lock Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-emulation@freebsd.org, freebsd-current@freebsd.org Subject: Re: flash10 vs f10; em(4) now broken in -current in qemu/vbox X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 21:12:14 -0000 Your change would work, but as its shared code and there are other OS's and their issues to worry about, what I am going to do is a bit different. I am including a patch if you would try this now, there will be a full driver update soon. Anyone set up to test this please post your results here. Cheers, Jack --- /usr/src/sys/dev/e1000/e1000_82540.c 2009-04-09 17:05:46.000000000 -0700 +++ ./e1000_82540.c 2009-06-09 18:47:24.000000000 -0700 @@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ -/*$FreeBSD: src/sys/dev/e1000/e1000_82540.c,v 1.3 2009/04/10 00:05:46 jfv Exp $*/ +/*$FreeBSD: $*/ /* * 82540EM Gigabit Ethernet Controller @@ -57,6 +57,7 @@ static s32 e1000_setup_copper_link_82540(struct e1000_hw *hw); static s32 e1000_setup_fiber_serdes_link_82540(struct e1000_hw *hw); static void e1000_power_down_phy_copper_82540(struct e1000_hw *hw); +static s32 e1000_read_mac_addr_82540(struct e1000_hw *hw); /** * e1000_init_phy_params_82540 - Init PHY func ptrs. @@ -229,6 +230,8 @@ mac->ops.clear_vfta = e1000_clear_vfta_generic; /* setting MTA */ mac->ops.mta_set = e1000_mta_set_generic; + /* read mac address */ + mac->ops.read_mac_addr = e1000_read_mac_addr_82540; /* ID LED init */ mac->ops.id_led_init = e1000_id_led_init_generic; /* setup LED */ @@ -676,3 +679,45 @@ E1000_READ_REG(hw, E1000_MGTPTC); } +/** + * e1000_read_mac_addr_82540 - Read device MAC address + * @hw: pointer to the HW structure + * + * Reads the device MAC address from the EEPROM and stores the value. + * Since devices with two ports use the same EEPROM, we increment the + * last bit in the MAC address for the second port. + * + * This version is being used over generic because of customer issues + * with VmWare and Virtual Box when using generic. It seems in + * the emulated 82545, RAR[0] does NOT have a valid address after a + * reset, this older method works and using this breaks nothing for + * these legacy adapters. + **/ +s32 e1000_read_mac_addr_82540(struct e1000_hw *hw) +{ + s32 ret_val = E1000_SUCCESS; + u16 offset, nvm_data, i; + + DEBUGFUNC("e1000_read_mac_addr"); + + for (i = 0; i < ETH_ADDR_LEN; i += 2) { + offset = i >> 1; + ret_val = hw->nvm.ops.read(hw, offset, 1, &nvm_data); + if (ret_val) { + DEBUGOUT("NVM Read Error\n"); + goto out; + } + hw->mac.perm_addr[i] = (u8)(nvm_data & 0xFF); + hw->mac.perm_addr[i+1] = (u8)(nvm_data >> 8); + } + + /* Flip last bit of mac address if we're on second port */ + if (hw->bus.func == E1000_FUNC_1) + hw->mac.perm_addr[5] ^= 1; + + for (i = 0; i < ETH_ADDR_LEN; i++) + hw->mac.addr[i] = hw->mac.perm_addr[i]; + +out: + return ret_val; +} On Tue, Jun 9, 2009 at 12:51 PM, Juergen Lock wrote: > On Tue, Jun 09, 2009 at 11:04:46AM -0700, Jack Vogel wrote: > > There is a change coming that will resolve this, stay tuned. > > Cool, thanx! :) > > Btw I posted patches too a few days later, in case you didn't see: > (I just noticed -current appears to have been dropped from the Cc somehow > so they only went to -emulation...) > > http://lists.freebsd.org/pipermail/freebsd-emulation/2009-June/006292.html > and for qemu: > > http://lists.freebsd.org/pipermail/freebsd-emulation/2009-June/006293.html > > Thanx again, > Juergen >