From owner-freebsd-emulation@FreeBSD.ORG Sun Jun 7 17:30:45 2009 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6FFF1065697 for ; Sun, 7 Jun 2009 17:30:45 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id A6B908FC19 for ; Sun, 7 Jun 2009 17:30:45 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id 4B1CA1E00236; Sun, 7 Jun 2009 19:30:44 +0200 (CEST) Received: from triton.kn-bremen.de (noident@localhost [127.0.0.1]) by triton.kn-bremen.de (8.14.3/8.14.3) with ESMTP id n57HRDP9012511; Sun, 7 Jun 2009 19:27:13 +0200 (CEST) (envelope-from nox@triton.kn-bremen.de) Received: (from nox@localhost) by triton.kn-bremen.de (8.14.3/8.14.3/Submit) id n57HRCZK012510; Sun, 7 Jun 2009 19:27:12 +0200 (CEST) (envelope-from nox) Date: Sun, 7 Jun 2009 19:27:12 +0200 (CEST) From: Juergen Lock Message-Id: <200906071727.n57HRCZK012510@triton.kn-bremen.de> To: sebosik@demax.sk X-Newsgroups: local.list.freebsd.emulation In-Reply-To: <4A2BC96B.9010209@demax.sk> Organization: home Cc: freebsd-emulation@freebsd.org Subject: em(4) patch for qemu/kvm/vbox guests (was: Re: flash10 vs f10; em(4) now broken in -current in qemu/vbox) 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: Sun, 07 Jun 2009 17:30:46 -0000 In article <4A2BC96B.9010209@demax.sk> you write: >Hi > >I think its caused by internal control of MAC address validity in >freebsd-sources ( sys/dev/e1000/if_em.c ) on line 4950. >You can safely remove references to that function + function itself and than >happily use if_em undex VBox as before. Actually that wasn't it, in fact commit 190872 changed the way mac addresses are read (e1000_read_mac_addr_generic() in sys/dev/e1000/e1000_nvm.c) - if I add the old way back for the case that the new code gets all zeros em(4) works again: Index: sys/dev/e1000/e1000_nvm.c @@ -820,20 +820,45 @@ u32 rar_high; u32 rar_low; u16 i; + s32 ret_val = E1000_SUCCESS; + + DEBUGFUNC("e1000_read_mac_addr"); rar_high = E1000_READ_REG(hw, E1000_RAH(0)); rar_low = E1000_READ_REG(hw, E1000_RAL(0)); - for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) - hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); + /* Fall back to reading from actual EEPROM like this code used to do + * in case we got all zeroes. (This fixes qemu/kvm/vbox guests.) + */ + if (!rar_low && !rar_high) { + u16 offset, nvm_data; + + 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); + } - for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) - hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*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; + } else { + for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) + hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); + for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) + hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8)); + } for (i = 0; i < ETH_ADDR_LEN; i++) hw->mac.addr[i] = hw->mac.perm_addr[i]; - return E1000_SUCCESS; +out: + return ret_val; } /**