Author: adrian
Date: Sat Apr  2 03:48:15 2011
New Revision: 220260
URL: http://svn.freebsd.org/changeset/base/220260

Log:
  A handful of the openwrt devices use a MAC address that's at a hard-coded
  offset in the flash.
  
  Some devices (eg the TPLink WR-1043ND) don't have a flash environment
  partition which can be queried for the current board settings.
  
  This particular workaround allows for image creators to use a hint
  to set the base MAC address. For example:
  
  hint.arge.0.eeprommac=0x1f01fc00

Modified:
  head/sys/mips/atheros/if_arge.c

Modified: head/sys/mips/atheros/if_arge.c
==============================================================================
--- head/sys/mips/atheros/if_arge.c     Sat Apr  2 00:27:22 2011        
(r220259)
+++ head/sys/mips/atheros/if_arge.c     Sat Apr  2 03:48:15 2011        
(r220260)
@@ -227,11 +227,32 @@ arge_attach(device_t dev)
        uint32_t                reg, rnd;
        int                     is_base_mac_empty, i, phys_total;
        uint32_t                hint;
+       long                    eeprom_mac_addr = 0;
 
        sc = device_get_softc(dev);
        sc->arge_dev = dev;
        sc->arge_mac_unit = device_get_unit(dev);
 
+       /*
+        * Some units (eg the TP-Link WR-1043ND) do not have a convenient
+        * EEPROM location to read the ethernet MAC address from.
+        * OpenWRT simply snaffles it from a fixed location.
+        *
+        * 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.
+        */
+       if (sc->arge_mac_unit == 0 &&
+           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];
+               }
+       }
+
        KASSERT(((sc->arge_mac_unit == 0) || (sc->arge_mac_unit == 1)), 
            ("if_arge: Only MAC0 and MAC1 supported"));
 
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to