From ryanb@goddamnbastard.org  Tue Oct 15 06:20:41 2002
Return-Path: <ryanb@goddamnbastard.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 5058237B401; Tue, 15 Oct 2002 06:20:41 -0700 (PDT)
Received: from jesper.goddamnbastard.org (12-251-154-208.client.attbi.com [12.251.154.208])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id B63E843E3B; Tue, 15 Oct 2002 06:20:40 -0700 (PDT)
	(envelope-from ryanb@goddamnbastard.org)
Received: by jesper.goddamnbastard.org (Postfix, from userid 1000)
	id D19B81549D; Tue, 15 Oct 2002 08:20:39 -0500 (CDT)
Message-Id: <20021015132039.D19B81549D@jesper.goddamnbastard.org>
Date: Tue, 15 Oct 2002 08:20:39 -0500 (CDT)
From: ryan beasley <ryanb@goddamnbastard.org>
Reply-To: ryan beasley <ryanb@goddamnbastard.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: Martin Blapp <mbr@freebsd.org>, Stephen McKay <mckay@freebsd.org>
Subject: dc(4) assigns incorrect link address with Davicom DM9102A chipsets
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         44092
>Category:       kern
>Synopsis:       dc(4) assigns incorrect link address with Davicom DM9102A chipsets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mbr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 15 06:30:02 PDT 2002
>Closed-Date:    Wed Feb 19 16:33:55 PST 2003
>Last-Modified:  Wed Feb 19 16:33:55 PST 2003
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:

 	  dc0: <Davicom DM9102A 10/100BaseTX> port 0xd400-0xd4ff mem
           0xfeaffc00-0xfeaffcff irq 9 at device 2.0 on pci2
           dc0: Ethernet address: 15:01:15:01:15:01
           miibus0: <MII bus> on dc0
           ukphy0: <Generic IEEE 802.3u media interface> on miibus0
           ukphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
 
 	Please note the bogus MAC address.  Setting this address manually
 	allowed me to configure and use the interface properly.
 
 	p.s.: I'm really curious as to why dc_read_eeprom isn't doing the
 	trick for this NIC under -CURRENT while still working under
 	4.6.2-p2.
 
>How-To-Repeat:
	Simply boot a kernel with this card / driver combination or load the
	if_dc module.
>Fix:
	Davicom published a datasheet for this chipset.  The serial ROM
	layout is detailed on page 54, so rather than trying to digest
	EEPROM-related code, I took the easy way out by copying the MAC
	address from the SROM portion.

	<URL:http://www.davicom8.com/download/Data%20Sheet/DM9102A-DS-F07-041202s.pdf>

	Patch included.

# made against if_dcreg.h 1.27 and if_dc.c 1.81
--- sys/pci/if_dcreg.h.orig	Tue Oct 15 07:44:12 2002
+++ sys/pci/if_dcreg.h	Tue Oct 15 07:42:37 2002
@@ -856,6 +856,11 @@
 #define DC_REVISION_DM9102A	0x30
 
 /*
+ * DM9102A MAC address SROM offset.
+ */
+#define	DC_DM9102_NODEADDR	0x14
+
+/*
  * ADMtek vendor ID.
  */
 #define DC_VENDORID_ADMTEK	0x1317
--- sys/pci/if_dc.c.orig	Tue Oct 15 07:44:08 2002
+++ sys/pci/if_dc.c	Tue Oct 15 07:42:29 2002
@@ -1995,6 +1995,9 @@
 		command &= 0xFFFF00FF;
 		command |= 0x00008000;
 		pci_write_config(dev, DC_PCI_CFLT, command, 4);
+		/* Copy out SROM portion for future use. */
+		dc_eeprom_width(sc);
+		dc_read_srom(sc, sc->dc_romwidth);
 		break;
 	case DC_DEVICEID_AL981:
 		sc->dc_type = DC_TYPE_AL981;
@@ -2142,6 +2145,9 @@
 		dc_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 1);
 		break;
 	case DC_TYPE_DM9102:
+		bcopy(&sc->dc_srom[DC_DM9102_NODEADDR], (caddr_t)&eaddr,
+		    ETHER_ADDR_LEN);
+		break;
 	case DC_TYPE_21143:
 	case DC_TYPE_ASIX:
 		dc_read_eeprom(sc, (caddr_t)&eaddr, DC_EE_NODEADDR, 3, 0);
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: keramida 
Responsible-Changed-When: Wed Oct 16 05:14:40 PDT 2002 
Responsible-Changed-Why:  
Misfiled PR: 
Fill the Category: field and assign this to freebsd-bus. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44092 

From: Giorgos Keramidas <keramida@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/44092: dc(4) assigns incorrect link address with Davicom DM9102A chipsets
Date: Sat, 1 Feb 2003 05:43:49 +0200

 [-- Adding to audit trail --]
 
 : Message-Id: <20030127083701.GK49658@goddamnbastard.org>
 : Date: Mon, 27 Jan 2003 02:37:01 -0600
 : From: ryan beasley <ryanb@goddamnbastard.org>
 : To: freebsd-gnats-submit@freebsd.org
 : Cc: Warner Losh <imp@village.org>
 : Subject: pending/47537: Re: dc(4) assigns incorrect link address with Davicom DM9102A chipsets
 :
 : As it turns out, everything but the first chunk of the if_dc.c patch is
 : bogus.  It is necessary to perform the SROM read as dc_romwidth is
 : referenced later on in dc_eeprom_putbyte.  The attached patch is just a
 : trimmed version of the first one submitted, and it seems to do the job.
 :
 : I'm cc'ng Warner since he committed the dynamically sized srom code.
 :
 : Index: src/sys/pci/if_dc.c
 : --- sys/pci/if_dc.c.orig	Mon Jan 27 02:15:04 2003
 : +++ sys/pci/if_dc.c	Mon Jan 27 02:12:33 2003
 : @@ -1979,6 +1983,8 @@
 :  		command &= 0xFFFF00FF;
 :  		command |= 0x00008000;
 :  		pci_write_config(dev, DC_PCI_CFLT, command, 4);
 : +		dc_eeprom_width(sc);
 : +		dc_read_srom(sc, sc->dc_romwidth);
 :  		break;
 :  	case DC_DEVICEID_AL981:
 :  		sc->dc_type = DC_TYPE_AL981;
Responsible-Changed-From-To: freebsd-bugs->mbr 
Responsible-Changed-By: mbr 
Responsible-Changed-When: Sat Feb 8 00:11:20 PST 2003 
Responsible-Changed-Why:  
Hi Stephen, 

Is this now fixed by this patch here ? 

http://people.freebsd.org/~mbr/patches/if_dc.c-MFC.diff 

Thank you very much for trying it out. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44092 
State-Changed-From-To: open->analyzed 
State-Changed-By: mbr 
State-Changed-When: Sat Feb 8 00:13:06 PST 2003 
State-Changed-Why:  
I think this will be fixed for 4.8  

http://www.freebsd.org/cgi/query-pr.cgi?pr=44092 
State-Changed-From-To: analyzed->closed 
State-Changed-By: mbr 
State-Changed-When: Wed Feb 19 16:33:35 PST 2003 
State-Changed-Why:  
Fixed in CURRENT and STABLE. Feedback timeout. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44092 
>Unformatted:
