/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* These functions are used to encode SAS SMP address data into
* Solaris devid / guid values.
*/
#ifndef _KERNEL
#include <stdio.h>
#endif /* _KERNEL */
#include <sys/inttypes.h>
#include <sys/isa_defs.h>
#include <sys/dditypes.h>
#include <sys/ddi_impldefs.h>
#ifndef _KERNEL
#include <sys/libdevid.h>
#endif /* !_KERNEL */
#include "devid_impl.h"
/*
* Typically the wwnstr makes a good devid, however in some cases the wwnstr
* comes form the location of a FRU in the chassis instead of from the identity
* These vidpid strings are matched against smp_report_manufacturer_info_resp
* data. When a match occurs the srmir_vs_52 field, if non-zero, is used
* to form the devid.
*/
char *vidpid_devid_from_srmir_vs_52[] = {
/* " 111111" */
/* "012345670123456789012345" */
/* "|-VID--||-----PID------|" */
"SUN GENESIS",
};
/*
* Function: ddi_/devid_smp_encode
*
* Description: This routine finds and encodes a unique devid given the
* SAS address of an SMP node.
*
* Arguments: version - id encode algorithm version
* driver_name - binding driver name (if ! known use NULL)
* wwnstr - smp SAS address in wwnstr (unit-address) form.
* srmir_buf - REPORT MANUFACTURER INFORMATION response.
* srmir_len - amount of srmir_buf data.
* devid - id returned
*
* Return Code: DEVID_SUCCESS - success
* DEVID_FAILURE - failure
*/
int
#ifdef _KERNEL
#else /* ! _KERNEL */
#endif /* _KERNEL */
int version, /* IN */
char *driver_name, /* IN */
char *wwnstr, /* IN */
{
int i_devid_len;
int i;
char **vidpid;
uint64_t s;
int driver_name_len = 0;
/* verify valid version */
return (DEVID_FAILURE);
return (DEVID_FAILURE);
/* convert wwnstr to binary */
return (DEVID_FAILURE);
if (srmir_buf &&
sizeof (*srmir)))) {
break;
goto usewwn;
/* extract the special vendor-specific 'devid serial number' */
/* discount zero value */
if (s == 0)
goto usewwn;
/* compute length (with trailing spaces removed) */
sizeof (srmir->srmir_vendor_identification));
sizeof (srmir->srmir_product_identification));
goto usewwn;
/* this is most like a devid formed from inquiry data */
i_devid_len = sizeof (*i_devid) +
return (DEVID_FAILURE);
/* copy the vid to the beginning */
/* copy the pid after the "vid." */
/* place the 'devid serial number' buffer the "vid.pid." */
} else {
raw_id_len = sizeof (wwn);
i_devid_len = sizeof (*i_devid) +
return (DEVID_FAILURE);
/* binary devid stores wwn bytes in big-endian order */
for (i = 0; i < sizeof (wwn); i++)
((i + 1) * 8))) & 0xFF;
}
/* fill in driver name hint */
if (driver_name != NULL) {
if (driver_name_len > DEVID_HINT_SIZE) {
/* pick up last four characters of driver name */
}
}
/* return device id */
return (DEVID_SUCCESS);
}