svn commit: r254690 - in head/sys/mips: atheros conf

Sean Bruno sbruno at FreeBSD.org
Fri Aug 23 13:14:19 UTC 2013


Author: sbruno
Date: Fri Aug 23 13:14:18 2013
New Revision: 254690
URL: http://svnweb.freebsd.org/changeset/base/254690

Log:
  Some vendors store the mac addresses of arge(4) as a literal sring in the
  form xx:xx:xx:xx:xx:xx complete with ":" characters taking of 18 bytes
  instead of 6 integers.  Expose a "readascii" tuneable to handle this case.
  
  Remove restriction on eepromac assignement for the first dev instance only.
  
  Add eepromac address for DIR-825 to hints file.
  
  Add readascii hint for DIR-825
  
  Reviewed by:	adrian@

Modified:
  head/sys/mips/atheros/if_arge.c
  head/sys/mips/conf/DIR-825.hints

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c	Fri Aug 23 12:42:13 2013	(r254689)
+++ head/sys/mips/atheros/if_arge.c	Fri Aug 23 13:14:18 2013	(r254690)
@@ -371,6 +371,7 @@ arge_attach(device_t dev)
 	uint32_t		hint;
 	long			eeprom_mac_addr = 0;
 	int			miicfg = 0;
+	int			readascii = 0;
 
 	sc = device_get_softc(dev);
 	sc->arge_dev = dev;
@@ -384,16 +385,28 @@ arge_attach(device_t dev)
 	 * Since multiple units seem to use this feature, include
 	 * a method of setting the MAC address based on an flash location
 	 * in CPU address space.
+	 *
+	 * Some vendors have decided to store the mac address as a literal
+	 * string of 18 characters in xx:xx:xx:xx:xx:xx format instead of
+	 * an array of numbers.  Expose a hint to turn on this conversion
+	 * feature via strtol()
 	 */
-	if (sc->arge_mac_unit == 0 &&
-	    resource_long_value(device_get_name(dev), device_get_unit(dev),
+	 if (resource_long_value(device_get_name(dev), device_get_unit(dev),
 	    "eeprommac", &eeprom_mac_addr) == 0) {
 		int i;
 		const char *mac =
 		    (const char *) MIPS_PHYS_TO_KSEG1(eeprom_mac_addr);
 		device_printf(dev, "Overriding MAC from EEPROM\n");
-		for (i = 0; i < 6; i++) {
-			ar711_base_mac[i] = mac[i];
+		if (resource_int_value(device_get_name(dev), device_get_unit(dev),
+			"readascii", &readascii) == 0) {
+			device_printf(dev, "Vendor stores MAC in ASCII format\n");
+			for (i = 0; i < 6; i++) {
+				ar711_base_mac[i] = strtol(&(mac[i*3]), NULL, 16);
+			}
+		} else {
+			for (i = 0; i < 6; i++) {
+				ar711_base_mac[i] = mac[i];
+			}
 		}
 	}
 

Modified: head/sys/mips/conf/DIR-825.hints
==============================================================================
--- head/sys/mips/conf/DIR-825.hints	Fri Aug 23 12:42:13 2013	(r254689)
+++ head/sys/mips/conf/DIR-825.hints	Fri Aug 23 13:14:18 2013	(r254690)
@@ -6,13 +6,14 @@
 hint.arge.0.phymask=0x0
 hint.arge.0.media=1000
 hint.arge.0.fduplex=1
-
-# XXX grab these from uboot?
-# hint.arge.0.eeprommac=0x1f01fc00
+hint.arge.0.eeprommac=0x1f66ffa0
+hint.arge.0.readascii=1
 
 hint.arge.1.phymask=0x0
 hint.arge.1.media=1000
 hint.arge.1.fduplex=1
+hint.arge.1.eeprommac=0x1f66ffb4
+hint.arge.1.readascii=1
 
 # ath0 - slot 17
 hint.pcib.0.bus.0.17.0.ath_fixup_addr=0x1f661000


More information about the svn-src-head mailing list