Source-Changes-HG archive

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

[src/trunk]: src/sys for SPI devices, allow platform code to set "scsi-initia...



details:   https://anonhg.NetBSD.org/src/rev/60ea96d4ecaf
branches:  trunk
changeset: 765319:60ea96d4ecaf
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue May 24 10:08:03 2011 +0000

description:
for SPI devices, allow platform code to set "scsi-initiator-id" device
property, and if set, use it instead of pfp.PortSCSIID.

on sparc64 systems on "scsi" or "scsi-2" devices, look from our node
up the tree for a "scsi-initiator-id" property, and if present, copy
it into the device properties.

this fixes mpt(4) issues on PRIMEPOWER250 (and probably other) systems.
idea from freebsd r207243/r207287, but reworked to use our device
properties instead of platform #ifdefs.


look in "device_type" as well as "name" for "ethernet" or "network",
and also look to see if a "local-mac-address" is set when choosing if
this may be a network device.  fixes bge(4) nul ethernet address on
the same PRIMEPOWER250.

diffstat:

 sys/arch/sparc64/sparc64/autoconf.c |  39 ++++++++++++++++++++++++++++++++----
 sys/dev/ic/mpt.c                    |  16 +++++++++++---
 2 files changed, 46 insertions(+), 9 deletions(-)

diffs (150 lines):

diff -r 4e2a837ada3d -r 60ea96d4ecaf sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Tue May 24 09:28:03 2011 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Tue May 24 10:08:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.177 2011/05/12 05:42:22 mrg Exp $ */
+/*     $NetBSD: autoconf.c,v 1.178 2011/05/24 10:08:03 mrg Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.177 2011/05/12 05:42:22 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.178 2011/05/24 10:08:03 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -938,16 +938,22 @@
        if (ofnode != 0) {
                uint8_t eaddr[ETHER_ADDR_LEN];
                char tmpstr[32];
+               char tmpstr2[32];
+               int node;
+               uint32_t id = 0;
                uint64_t nwwn = 0, pwwn = 0;
                prop_dictionary_t dict;
                prop_data_t blob;
                prop_number_t pwwnd = NULL, nwwnd = NULL;
+               prop_number_t idd = NULL;
 
                device_setofnode(dev, ofnode);
                dev_path_exact_match(dev, ofnode);
 
                if (OF_getprop(ofnode, "name", tmpstr, sizeof(tmpstr)) <= 0)
                        tmpstr[0] = 0;
+               if (OF_getprop(ofnode, "device_type", tmpstr2, sizeof(tmpstr2)) <= 0)
+                       tmpstr2[0] = 0;
 
                /*
                 * If this is a network interface, note the
@@ -955,7 +961,11 @@
                 */
                if (strcmp(tmpstr, "network") == 0
                   || strcmp(tmpstr, "ethernet") == 0
+                  || strcmp(tmpstr2, "network") == 0
+                  || strcmp(tmpstr2, "ethernet") == 0
                   || OF_getprop(ofnode, "mac-address", &eaddr, sizeof(eaddr))
+                     >= ETHER_ADDR_LEN
+                  || OF_getprop(ofnode, "local-mac-address", &eaddr, sizeof(eaddr))
                      >= ETHER_ADDR_LEN) {
 
                        dict = device_properties(dev);
@@ -963,7 +973,8 @@
                        /*
                         * Is it a network interface with FCode?
                         */
-                       if (strcmp(tmpstr, "network") == 0) {
+                       if (strcmp(tmpstr, "network") == 0 ||
+                           strcmp(tmpstr2, "network") == 0) {
                                prop_dictionary_set_bool(dict,
                                    "without-seeprom", true);
                                prom_getether(ofnode, eaddr);
@@ -980,8 +991,7 @@
 noether:
 
                /* is this a FC node? */
-               if (OF_getprop(ofnode, "device_type", tmpstr,
-                   sizeof(tmpstr)) > 0 && strcmp(tmpstr, "scsi-fcp") == 0) {
+               if (strcmp(tmpstr, "scsi-fcp") == 0) {
 
                        dict = device_properties(dev);
 
@@ -1001,6 +1011,25 @@
                                prop_object_release(nwwnd);
                        }
                }
+
+               /* is this an spi device?  look for scsi-initiator-id */
+               if (strcmp(tmpstr2, "scsi") == 0 ||
+                   strcmp(tmpstr2, "scsi-2") == 0) {
+
+                       dict = device_properties(dev);
+
+                       for (node = ofnode; node != 0; node = OF_parent(node)) {
+                               if (OF_getprop(node, "scsi-initiator-id", &id,
+                                   sizeof(id)) <= 0)
+                                       continue;
+
+                               idd = prop_number_create_unsigned_integer(id);
+                               prop_dictionary_set(dict,
+                                                   "scsi-initiator-id", idd);
+                               prop_object_release(idd);
+                               break;
+                       }
+               }
        }
 
        /*
diff -r 4e2a837ada3d -r 60ea96d4ecaf sys/dev/ic/mpt.c
--- a/sys/dev/ic/mpt.c  Tue May 24 09:28:03 2011 +0000
+++ b/sys/dev/ic/mpt.c  Tue May 24 10:08:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mpt.c,v 1.14 2010/04/28 22:45:27 chs Exp $     */
+/*     $NetBSD: mpt.c,v 1.15 2011/05/24 10:08:03 mrg Exp $     */
 
 /*
  * Copyright (c) 2000, 2001 by Greg Ansley
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.14 2010/04/28 22:45:27 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpt.c,v 1.15 2011/05/24 10:08:03 mrg Exp $");
 
 #include <dev/ic/mpt.h>
 
@@ -1131,7 +1131,9 @@
         int try;
         MSG_IOC_FACTS_REPLY facts;
         MSG_PORT_FACTS_REPLY pfp;
-       u_int32_t pptr;
+        prop_dictionary_t dict;
+        uint32_t ini_id;
+        uint32_t pptr;
         int val;
 
        /* Put all request buffers (back) on the free list */
@@ -1151,6 +1153,8 @@
        if (mpt_hw_init(mpt) != 0)
                return (EIO);
 
+       dict = device_properties(&mpt->sc_dev);
+
        for (try = 0; try < MPT_MAX_TRYS; try++) {
                /*
                 * No need to reset if the IOC is already in the READY state.
@@ -1209,7 +1213,11 @@
                        return (ENXIO);
                }
 
-               mpt->mpt_ini_id = pfp.PortSCSIID;
+               if (!mpt->is_sas && !mpt->is_fc &&
+                   prop_dictionary_get_uint32(dict, "scsi-initiator-id", &ini_id))
+                       mpt->mpt_ini_id = ini_id;
+               else
+                       mpt->mpt_ini_id = pfp.PortSCSIID;
 
                if (mpt_send_ioc_init(mpt, who) != MPT_OK) {
                        mpt_prt(mpt, "mpt_send_ioc_init failed");



Home | Main Index | Thread Index | Old Index