From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 19 10:46:32 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3450216A403 for ; Mon, 19 Mar 2007 10:46:32 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.242]) by mx1.freebsd.org (Postfix) with ESMTP id DB26A13C487 for ; Mon, 19 Mar 2007 10:46:31 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by an-out-0708.google.com with SMTP id c24so1141253ana for ; Mon, 19 Mar 2007 03:46:31 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:received:received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=hAQj8whJgzuF98xy4GkdYkJufj2HZGWtMgS8rA6h4ROM3ZIomvravuQ+kDUfnM2eo0Dvcc+/7ML0RIlXqAxozZaYpM/LA7A7JKG6HPjAu549X5+AuTVsDSuohnXS+44msvV1oIbRGIRn6rfK+QuaPTzsRJg5aERP/IsOyIHLfQw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:cc:subject:message-id:reply-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; b=dDK4c93LMEbjZxnwfxNLjV1GAePPq/RMOl7t6QAQQW+FLzGMGaokgwhbGOGc6YqhmuwPHrFoDIAnpW5NxkK4uoR7RtmqwiIDeROw/LKuU1ss2g8jNBcavUuk/NBAYnowEY21BCTLLRrSEWAQycx4n0W3adDENPjZCNI6T6lFMa4= Received: by 10.65.233.16 with SMTP id k16mr7401349qbr.1174299671286; Mon, 19 Mar 2007 03:21:11 -0700 (PDT) Received: from michelle.cdnetworks.co.kr ( [211.53.35.84]) by mx.google.com with ESMTP id 17sm24190195nzo.2007.03.19.03.21.07; Mon, 19 Mar 2007 03:21:09 -0700 (PDT) Received: from michelle.cdnetworks.co.kr (localhost.cdnetworks.co.kr [127.0.0.1]) by michelle.cdnetworks.co.kr (8.13.5/8.13.5) with ESMTP id l2JAOkCx015555 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Mar 2007 19:24:46 +0900 (KST) (envelope-from pyunyh@gmail.com) Received: (from yongari@localhost) by michelle.cdnetworks.co.kr (8.13.5/8.13.5/Submit) id l2JAOia8015554; Mon, 19 Mar 2007 19:24:44 +0900 (KST) (envelope-from pyunyh@gmail.com) Date: Mon, 19 Mar 2007 19:24:44 +0900 From: Pyun YongHyeon To: Andriy Gapon Message-ID: <20070319102444.GD13303@cdnetworks.co.kr> References: <45FACBE4.5090403@icyb.net.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45FACBE4.5090403@icyb.net.ua> User-Agent: Mutt/1.4.2.1i Cc: freebsd-hackers@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: nve: ethernet address reversal code X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Mar 2007 10:46:32 -0000 On Fri, Mar 16, 2007 at 06:55:00PM +0200, Andriy Gapon wrote: > > I am wondering what is the purpose of the following pieces of code in > if_nve.c: > > /* ... nve_attach ... */ > /* MAC is loaded backwards into h/w reg */ > sc->hwapi->pfnGetNodeAddress(sc->hwapi->pADCX, sc->original_mac_addr); > for (i = 0; i < 6; i++) { > eaddr[i] = sc->original_mac_addr[5 - i]; > } > sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, eaddr); > bcopy(eaddr, (char *)&sc->sc_macaddr, ETHER_ADDR_LEN); > > > /* ... nve_detach ... */ > /* Reload unreversed address back into MAC in original state */ > if (sc->original_mac_addr) > sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, > sc->original_mac_addr); > > Small note: pointer check in nve_detach is obviously not needed because > sc->original_mac_addr is not a pointer but an array. > > > I am asking the question for two reasons: > > 1. [theoretical] I am not sure what pfnSetNodeAddress() is doing, but if > it makes modification in NIC memory that can persist across PC reset or > poweroff, then this code can be dangerous if a machine crashes/hangs/etc. > > 2. [practical] I recently installed 6.2-RELEASE amd64 on Asus M2N > machine (chipset nForce 430 MCP == MCP61, onboard NIC pci chip id is > 03ef). After a small patch to add this ID to nve everything worked very > well (in 1 Gb mode). That is, almost everything: I had a very strange > problems access one particular machine on my LAN. I still don't know > what exactly was the problem, but during its investigation I noticed my > MAC address looked strange compared to other MAC addresses. You, we have > a bunch of machines with identical HW on our LAN, they all run either > Linux or Windows, mine is the only FreeBSD one. > So, my ethernet address was a5:07:9f:f3:18:00, but other guys had > something like 00:18:f3:9f:XX:YY. After some digging around I went into > the sources, changed [5-i] to [i] and everything started to work perfectly. > Then I looked at some other machine that uses nve: FreeBSD 6.1 i386, > Abit NF7 motherboard (nForce2 chipset). MAC address there is > 00:50:8d:4d:aa:83, which looks pretty normal. > > So I am wondering if this is a 64-bit thing or something specific to a > particular chipset. Unfortunately, I can not test i386 version of > FreeBSD (patched to recognize my chipset) on this hardware now. > > P.S. just in case, here's a verbose dmesg after both of my patches and > kldunload/kldload: > Mar 14 19:05:32 rein kernel: pci0:7:0: reprobing on driver added > Mar 14 19:05:32 rein kernel: nve0: Adapter> port 0xe480-0xe487 mem 0xddefd000-0xddefdfff irq 20 at device 7.0 > on pci0 > Mar 14 19:05:32 rein kernel: nve0: nvenetlib.o version 1.0-13 > Mar 14 19:05:32 rein kernel: nve0: Ethernet address 00:18:f3:9f:07:a5 > Mar 14 19:05:32 rein kernel: miibus0: on nve0 > Mar 14 19:05:32 rein kernel: ukphy0: interface> on miibus0 > Mar 14 19:05:32 rein kernel: ukphy0: OUI 0x001374, model 0x0001, rev. 6 > Mar 14 19:05:32 rein kernel: ukphy0: 10baseT, 10baseT-FDX, 100baseTX, > 100baseTX-FDX, 1000baseT-FDX, auto > Mar 14 19:05:32 rein kernel: nve0: bpf attached > Mar 14 19:05:32 rein kernel: nve0: Ethernet address: 00:18:f3:9f:07:a5 > Mar 14 19:05:32 rein kernel: nve0: [MPSAFE] > Mar 14 19:05:32 rein kernel: pci1: driver added > Mar 14 19:05:32 rein kernel: pci2: driver added > Mar 14 19:05:32 rein kernel: found-> vendor=0x10de, dev=0x016a, > revid=0xa1 > Mar 14 19:05:32 rein kernel: bus=2, slot=0, func=0 > Mar 14 19:05:32 rein kernel: class=03-00-00, hdrtype=0x00, mfdev=0 > Mar 14 19:05:32 rein kernel: cmdreg=0x0007, statreg=0x0010, cachelnsz=16 > (dwords) > Mar 14 19:05:32 rein kernel: lattimer=0x00 (0 ns), mingnt=0x00 (0 ns), > maxlat=0x00 (0 ns) > Mar 14 19:05:32 rein kernel: intpin=a, irq=16 > Mar 14 19:05:32 rein kernel: powerspec 2 supports D0 D3 current D0 > Mar 14 19:05:32 rein kernel: MSI supports 1 message, 64 bit > Unlike other MCP hardwares, MCP61/MCP65/MCP67 stores ethernet address in-order. nve(4)/nfe(4) should not swap ethernet address on these hardwares. Peer Chen at NVIDIA and Shigeaki Tagashira sent me patches to the issue and I've updated new nfe(4). If you use CURRENT, try updated nfe(4) at the following URL. http://people.freebsd.org/~yongari/if_nfe.c http://people.freebsd.org/~yongari/if_nfereg.h http://people.freebsd.org/~yongari/if_nfevar.h For more detailed revision history and RELENG_6 sources, see http://www.se.hiroshima-u.ac.jp/~shigeaki/software/freebsd-nfe.html -- Regards, Pyun YongHyeon