Module Name: src Committed By: mrg Date: Tue May 24 10:08:03 UTC 2011
Modified Files: src/sys/arch/sparc64/sparc64: autoconf.c src/sys/dev/ic: mpt.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/sys/arch/sparc64/sparc64/autoconf.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/mpt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/sparc64/sparc64/autoconf.c diff -u src/sys/arch/sparc64/sparc64/autoconf.c:1.177 src/sys/arch/sparc64/sparc64/autoconf.c:1.178 --- src/sys/arch/sparc64/sparc64/autoconf.c:1.177 Thu May 12 05:42:22 2011 +++ src/sys/arch/sparc64/sparc64/autoconf.c Tue May 24 10:08:03 2011 @@ -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; + } + } } /* Index: src/sys/dev/ic/mpt.c diff -u src/sys/dev/ic/mpt.c:1.14 src/sys/dev/ic/mpt.c:1.15 --- src/sys/dev/ic/mpt.c:1.14 Wed Apr 28 22:45:27 2010 +++ src/sys/dev/ic/mpt.c Tue May 24 10:08:03 2011 @@ -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");