Subject: Re: hme sbus mac address question
To: Julian Coleman <jdc@coris.org.uk>
From: Anthony Sofia <anthony@dryhump.net>
List: port-sparc
Date: 01/23/2004 18:24:21
Julian,

No dice. The mac address that gets set using the local-mac-address property
is not right. I was having the same problem and noticed nothing is actually
being retrieved from openboot during that PROM_getprop call.

Here is the correct mac address from one of the interfaces:
	ok cd iommu/sbus/SUNW,hme@1,8c30000
	ok .attributes
	local-mac-address        08 00 20 8d b8 c3
The other 3 interfaces are c0,c1,c2.

Here is the dmesg output for the hme interfaces after applying your patch:
	ledma0 at sbus0 slot 5 offset 0x8400010: DMA rev 2
	le0 at ledma0 slot 5 offset 0x8c00000 level 6: address 08:00:20:71:90:78
	le0: 8 receive buffers, 2 transmit buffers
	hme0 at sbus0 slot 1 offset 0x8c00000 level 4 (ipl 7): Sun Happy Meal Ethernet (SUNW,hme)
	Using "local-mac-address" property: hme0: Ethernet address f0:46:2a:20:00:00
	qsphy0 at hme0 phy 1: QS6612 10/100 media interface, rev. 1
	qsphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
	hme1 at sbus0 slot 1 offset 0x8c10000 level 4 (ipl 7): Sun Happy Meal Ethernet (SUNW,hme)
	Using "local-mac-address" property: hme1: Ethernet address f0:46:29:a0:00:00
	qsphy1 at hme1 phy 1: QS6612 10/100 media interface, rev. 1
	qsphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
	hme2 at sbus0 slot 1 offset 0x8c20000 level 4 (ipl 7): Sun Happy Meal Ethernet (SUNW,hme)
	Using "local-mac-address" property: hme2: Ethernet address f0:46:29:30:00:00
	qsphy2 at hme2 phy 1: QS6612 10/100 media interface, rev. 1
	qsphy2: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
	hme3 at sbus0 slot 1 offset 0x8c30000 level 4 (ipl 7): Sun Happy Meal Ethernet (SUNW,hme)
	Using "local-mac-address" property: hme3: Ethernet address f0:46:28:c0:00:00
	qsphy3 at hme3 phy 1: QS6612 10/100 media interface, rev. 1
	qsphy3: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto

Thanks for the help thus far.

On Thu, Jan 22, 2004 at 06:12:12PM +0000, Julian Coleman said:
>I've attached the updated patch that should get the correct local MAC
>addresses.  Setting the "local-mac-address" property on the HME card didn't
>work as I expected, so I haven't been able to test it completely.  It would
>be great if you could check that the MAC address that it shows is the same
>as the one in the PROM and also that the shown address appears in packets
>on the wire.
>
>Thanks,
>
>J
>
>-- 
>  My other computer also runs NetBSD    /        Sailing at Newbiggin
>        http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/  

>--- /usr/cvs/src/sys/dev/sbus/if_hme_sbus.c	Tue Dec 10 13:44:47 2002
>+++ if_hme_sbus.c	Thu Jan 22 17:59:52 2004
>@@ -99,7 +99,7 @@
> 	struct hme_softc *sc = &hsc->hsc_hme;
> 	struct sbusdev *sd = &hsc->hsc_sbus;
> 	u_int32_t burst, sbusburst;
>-	int node;
>+	int node, optionsnode, local_used = 0;
> 
> 	/* XXX the following declarations should be elsewhere */
> 	extern void myetheraddr __P((u_char *));
>@@ -173,7 +173,31 @@
> 	sd->sd_reset = (void *)hme_reset;
> 	sbus_establish(sd, self);
> 
>-	myetheraddr(sc->sc_enaddr);
>+	/*
>+	 * Check the "local-mac-address?" option and the nodes'
>+	 * "local-mac-address" and "mac-address" properties for a local
>+	 * MAC addresses.  Only the QFE card has "local-mac-address" but
>+	 * "mac-address" can be set when net-booting.
>+	 */
>+	optionsnode = prom_findnode(prom_firstchild(prom_findroot()),
>+	    "options");
>+	if (strcmp(PROM_getpropstring(optionsnode,
>+	    "local-mac-address?"), "true") == 0) {
>+		int nitem = 1;
>+		if (PROM_getprop(node, "local-mac-address",
>+		    ETHER_ADDR_LEN, &nitem, sc->sc_enaddr) == 0) {
>+			local_used = 1;
>+			printf("Using \"local-mac-address\" property: ");
>+		} else {
>+			if (PROM_getprop(node, "local-mac-address",
>+			    ETHER_ADDR_LEN, &nitem, sc->sc_enaddr) == 0) {
>+				local_used = 1;
>+				printf("Using \"mac-address\" property: ");
>+			}
>+		}
>+	}
>+	if (!local_used)
>+		myetheraddr(sc->sc_enaddr);
> 
> 	/*
> 	 * Get transfer burst size from PROM and pass it on

Anthony Sofia (anthony@dryhump.net)
--
I'll take care of those murderous trolls.