Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/sparc64 Add the mac address as device prope...



details:   https://anonhg.NetBSD.org/src/rev/cf92537aad5a
branches:  trunk
changeset: 750982:cf92537aad5a
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Jan 20 15:45:52 2010 +0000

description:
Add the mac address as device property "mac-address" to all devices that
look like a network interface.
Also add a boolean "without-seeprom" to all apparently on-board network
interface (which usually have no eeprom of their own on Suns), this
latter can be used to enable driver hacks.

diffstat:

 sys/arch/sparc64/sparc64/autoconf.c |  39 ++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 5 deletions(-)

diffs (75 lines):

diff -r c90a8b84ed68 -r cf92537aad5a sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Wed Jan 20 15:03:50 2010 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Wed Jan 20 15:45:52 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.163 2010/01/10 13:52:06 martin Exp $ */
+/*     $NetBSD: autoconf.c,v 1.164 2010/01/20 15:45:52 martin Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.163 2010/01/10 13:52:06 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.164 2010/01/20 15:45:52 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -76,6 +76,7 @@
 #include <prop/proplib.h>
 
 #include <net/if.h>
+#include <net/if_ether.h>
 
 #include <dev/cons.h>
 #include <sparc64/dev/cons.h>
@@ -906,17 +907,45 @@
                return;
 
        if (ofnode != 0) {
-               char devtype[32];
+               uint8_t eaddr[ETHER_ADDR_LEN];
+               char tmpstr[32];
                uint64_t nwwn = 0, pwwn = 0;
                prop_dictionary_t dict;
+               prop_data_t blob;
                prop_number_t pwwnd = NULL, nwwnd = NULL;
 
                device_setofnode(dev, ofnode);
                dev_path_exact_match(dev, ofnode);
 
+               if (OF_getprop(ofnode, "name", tmpstr, sizeof(tmpstr)) <= 0)
+                       tmpstr[0] = 0;
+
+               /*
+                * If this is a network interface, note the
+                * mac address.
+                */
+               if (strcmp(tmpstr, "network") == 0
+                  || strcmp(tmpstr, "ethernet") == 0
+                  || OF_getprop(ofnode, "mac-address", &eaddr, sizeof(eaddr))
+                     == sizeof(eaddr)) {
+                       prom_getether(ofnode, eaddr);
+                       dict = device_properties(dev);
+                       blob = prop_data_create_data(eaddr, ETHER_ADDR_LEN);
+                       prop_dictionary_set(dict, "mac-address", blob);
+                       prop_object_release(blob);
+               }
+               /*
+                * Is it a network interface with FCode? (others are called
+                * "ethernet" by the firmware)
+                */
+               if (strcmp(tmpstr, "network") == 0) {
+                       dict = device_properties(dev);
+                       prop_dictionary_set_bool(dict, "without-seeprom", true);
+               }
+
                /* is this a FC node? */
-               if (OF_getprop(ofnode, "device_type", devtype,
-                   sizeof(devtype)) > 0 && strcmp(devtype, "scsi-fcp") == 0) {
+               if (OF_getprop(ofnode, "device_type", tmpstr,
+                   sizeof(tmpstr)) > 0 && strcmp(tmpstr, "scsi-fcp") == 0) {
 
                        dict = device_properties(dev);
 



Home | Main Index | Thread Index | Old Index