xref: /onnv-gate/usr/src/lib/libprtdiag_psr/sparc/ontario/common/huron.c (revision 6954:0fcca026e3e7)
13156Sgirish /*
23156Sgirish  * CDDL HEADER START
33156Sgirish  *
43156Sgirish  * The contents of this file are subject to the terms of the
53156Sgirish  * Common Development and Distribution License (the "License").
63156Sgirish  * You may not use this file except in compliance with the License.
73156Sgirish  *
83156Sgirish  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
93156Sgirish  * or http://www.opensolaris.org/os/licensing.
103156Sgirish  * See the License for the specific language governing permissions
113156Sgirish  * and limitations under the License.
123156Sgirish  *
133156Sgirish  * When distributing Covered Code, include this CDDL HEADER in each
143156Sgirish  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
153156Sgirish  * If applicable, add the following below this CDDL HEADER, with the
163156Sgirish  * fields enclosed by brackets "[]" replaced with your own identifying
173156Sgirish  * information: Portions Copyright [yyyy] [name of copyright owner]
183156Sgirish  *
193156Sgirish  * CDDL HEADER END
203156Sgirish  */
213156Sgirish /*
22*6954Smb158278  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
233156Sgirish  * Use is subject to license terms.
243156Sgirish  */
253156Sgirish 
263156Sgirish /*
273156Sgirish  * Sun4v Platform specific functions.
283156Sgirish  *
293156Sgirish  * 	called when :
303156Sgirish  *      machine_type ==  huron
313156Sgirish  *
323156Sgirish  */
333156Sgirish 
343156Sgirish #pragma ident	"%Z%%M%	%I%	%E% SMI"
353156Sgirish 
363156Sgirish #include <stdio.h>
373156Sgirish #include <stdlib.h>
383156Sgirish #include <unistd.h>
393156Sgirish #include <kstat.h>
403156Sgirish #include <fcntl.h>
413156Sgirish #include <string.h>
423156Sgirish #include <assert.h>
433156Sgirish #include <libintl.h>
443156Sgirish #include <note.h>
453156Sgirish #include <sys/systeminfo.h>
463156Sgirish #include <sys/openpromio.h>
473156Sgirish #include <sys/sysmacros.h>
483156Sgirish #include <picl.h>
493156Sgirish #include "picldefs.h"
503156Sgirish #include <pdevinfo.h>
513156Sgirish #include <display.h>
523156Sgirish #include <display_sun4v.h>
533156Sgirish #include <libprtdiag.h>
543156Sgirish #include "huron.h"
553156Sgirish 
563156Sgirish #if !defined(TEXT_DOMAIN)
573156Sgirish #define	TEXT_DOMAIN	"SYS_TEST"
583156Sgirish #endif
593156Sgirish 
603156Sgirish static void
huron_get_bus_type(char * path,struct io_card * card)613156Sgirish huron_get_bus_type(char *path, struct io_card *card)
623156Sgirish {
633260Szx143588 	if (strcmp(path, HURON_NIU) == 0) {
643260Szx143588 		(void) strcpy(card->bus_type, "NIU");
653156Sgirish 	} else {
663156Sgirish 		(void) strcpy(card->bus_type, "PCIE");
673156Sgirish 	}
683156Sgirish }
693156Sgirish 
703156Sgirish void
huron_get_slot_number(char * path,struct io_card * card)713156Sgirish huron_get_slot_number(char *path, struct io_card *card)
723156Sgirish {
733156Sgirish 	if (strcmp(path, HURON_N2_XAUI0) == 0) {
743156Sgirish 		(void) strcpy(card->slot_str, "0");
753156Sgirish 		card->slot = 0;
763156Sgirish 	} else if (strcmp(path, HURON_N2_XAUI1) == 0) {
773156Sgirish 		(void) strcpy(card->slot_str, "1");
783156Sgirish 		card->slot = 1;
794012Szx143588 	} else if (strncmp(path, HURON_PCIE_SLOT0,
80*6954Smb158278 	    strlen(HURON_PCIE_SLOT0)) == 0) {
814012Szx143588 		(void) strcpy(card->slot_str, "0");
824012Szx143588 		card->slot = 0;
833156Sgirish 	} else if (strncmp(path, HURON_PCIE_SLOT1,
84*6954Smb158278 	    strlen(HURON_PCIE_SLOT1)) == 0) {
853156Sgirish 		(void) strcpy(card->slot_str, "1");
863156Sgirish 		card->slot = 1;
873156Sgirish 	} else if (strncmp(path, HURON_PCIE_SLOT2,
88*6954Smb158278 	    strlen(HURON_PCIE_SLOT2)) == 0) {
893156Sgirish 		(void) strcpy(card->slot_str, "2");
903156Sgirish 		card->slot = 2;
913156Sgirish 	} else if (strncmp(path, HURON_PCIE_SLOT3,
92*6954Smb158278 	    strlen(HURON_PCIE_SLOT3)) == 0) {
933156Sgirish 		(void) strcpy(card->slot_str, "3");
943156Sgirish 		card->slot = 3;
953156Sgirish 	} else if (strncmp(path, HURON_PCIE_SLOT4,
96*6954Smb158278 	    strlen(HURON_PCIE_SLOT4)) == 0) {
973156Sgirish 		(void) strcpy(card->slot_str, "4");
983156Sgirish 		card->slot = 4;
993156Sgirish 	} else if (strncmp(path, HURON_PCIE_SLOT5,
100*6954Smb158278 	    strlen(HURON_PCIE_SLOT5)) == 0) {
1013156Sgirish 		(void) strcpy(card->slot_str, "5");
1023156Sgirish 		card->slot = 5;
1033156Sgirish 	} else {
1043156Sgirish 		(void) strcpy(card->slot_str, MOTHERBOARD);
1053156Sgirish 		card->slot = NO_SLOT;
1063156Sgirish 	}
1073156Sgirish }
1083156Sgirish 
1093156Sgirish int
huron_get_network_instance(char * path)1103156Sgirish huron_get_network_instance(char *path)
1113156Sgirish {
1123156Sgirish 	if (strcmp(path, HURON_NETWORK_0) == 0) {
1133156Sgirish 		return (0);
1143156Sgirish 	} else if (strcmp(path, HURON_NETWORK_1) == 0) {
1153156Sgirish 		return (1);
1163156Sgirish 	} else if (strcmp(path, HURON_NETWORK_2) == 0) {
1173156Sgirish 		return (2);
1183156Sgirish 	} else if (strcmp(path, HURON_NETWORK_3) == 0) {
1193156Sgirish 		return (3);
1203156Sgirish 	} else if (strcmp(path, HURON_N2_XAUI0) == 0) {
1213156Sgirish 		return (0);
1223156Sgirish 	} else if (strcmp(path, HURON_N2_XAUI1) == 0) {
1233156Sgirish 		return (1);
1243156Sgirish 	} else {
1253156Sgirish 		return (-1);
1263156Sgirish 	}
1273156Sgirish }
1283156Sgirish /*
1293156Sgirish  * add all io devices under pci in io list
1303156Sgirish  */
1313156Sgirish /* ARGSUSED */
1323156Sgirish int
huron_pci_callback(picl_nodehdl_t pcih,void * args)1333156Sgirish huron_pci_callback(picl_nodehdl_t pcih, void *args)
1343156Sgirish {
1353156Sgirish 	int		err = PICL_SUCCESS;
1363156Sgirish 	picl_nodehdl_t	nodeh;
1373156Sgirish 	char		path[MAXSTRLEN];
1383156Sgirish 	char		parent_path[MAXSTRLEN];
1393156Sgirish 	char		piclclass[PICL_CLASSNAMELEN_MAX];
1403156Sgirish 	char		name[MAXSTRLEN];
1413156Sgirish 	char		model[MAXSTRLEN];
1423156Sgirish 	char		*compatible;
1433156Sgirish 	char		binding_name[MAXSTRLEN];
1443156Sgirish 	struct io_card	pci_card;
1453156Sgirish 	int32_t		instance;
1463156Sgirish 
1473156Sgirish 	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, parent_path,
1483156Sgirish 	    sizeof (parent_path));
1493156Sgirish 	if (err != PICL_SUCCESS) {
1503156Sgirish 		return (err);
1513156Sgirish 	}
1523156Sgirish 
1533156Sgirish 	/* Walk through the children */
1543156Sgirish 	err = picl_get_propval_by_name(pcih, PICL_PROP_CHILD, &nodeh,
1553156Sgirish 	    sizeof (picl_nodehdl_t));
1563156Sgirish 
1573156Sgirish 	while (err == PICL_SUCCESS) {
1583156Sgirish 		err = picl_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
1593156Sgirish 		    piclclass, sizeof (piclclass));
1603156Sgirish 		if (err !=  PICL_SUCCESS)
1613156Sgirish 			return (err);
1623156Sgirish 
1633156Sgirish 		if (strcmp(piclclass, "pciex") == 0) {
1643156Sgirish 			err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER,
1653156Sgirish 			    &nodeh, sizeof (picl_nodehdl_t));
1663156Sgirish 			continue;
1673156Sgirish 		}
1683156Sgirish 
1693260Szx143588 		if (strcmp(piclclass, "sun4v") == 0) {
1703156Sgirish 			err = picl_get_propval_by_name(nodeh, PICL_PROP_CHILD,
1713156Sgirish 			    &nodeh, sizeof (picl_nodehdl_t));
1723156Sgirish 			continue;
1733156Sgirish 		}
1743156Sgirish 
1753156Sgirish 		err = picl_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
1763156Sgirish 		    path, sizeof (path));
1773156Sgirish 		if (err != PICL_SUCCESS) {
1783156Sgirish 			return (err);
1793156Sgirish 		}
1803156Sgirish 
1813156Sgirish 		(void) strlcpy(pci_card.notes, path, sizeof (pci_card.notes));
1823156Sgirish 
1833156Sgirish 		huron_get_bus_type(parent_path, &pci_card);
1843156Sgirish 
1853156Sgirish 		err = picl_get_propval_by_name(nodeh, PICL_PROP_NAME, &name,
1863156Sgirish 		    sizeof (name));
1873156Sgirish 		if (err == PICL_PROPNOTFOUND)
1883156Sgirish 			(void) strcpy(name, "");
1893156Sgirish 		else if (err != PICL_SUCCESS)
1903156Sgirish 			return (err);
1913156Sgirish 
1923260Szx143588 		if (strcmp(parent_path, HURON_NIU) == 0)
1933260Szx143588 			huron_get_slot_number(path, &pci_card);
1943260Szx143588 		else
1953260Szx143588 			huron_get_slot_number(parent_path, &pci_card);
1963156Sgirish 
1973156Sgirish 		/* Figure NAC name */
1983156Sgirish 		if ((strcmp(name, NETWORK) == 0) &&
1993156Sgirish 		    (strcmp(pci_card.slot_str, MOTHERBOARD) == 0)) {
2003156Sgirish 			instance = huron_get_network_instance(path);
2013156Sgirish 			(void) snprintf(pci_card.status,
2023156Sgirish 			    sizeof (pci_card.status), "%s/%s%d", MOTHERBOARD,
2033156Sgirish 			    "NET", instance);
2043156Sgirish 		} else {
2053156Sgirish 			if (pci_card.slot != NO_SLOT) {
2063156Sgirish 				(void) snprintf(pci_card.status,
2073156Sgirish 				    sizeof (pci_card.status), "%s/%s%d",
2083156Sgirish 				    MOTHERBOARD, pci_card.bus_type,
2093156Sgirish 				    pci_card.slot);
2103156Sgirish 			} else {
2113156Sgirish 				(void) snprintf(pci_card.status,
2123156Sgirish 				    sizeof (pci_card.status), "%s/%s",
2133156Sgirish 				    MOTHERBOARD, pci_card.bus_type);
2143156Sgirish 			}
2153156Sgirish 		}
2163156Sgirish 
2173156Sgirish 		/*
2183156Sgirish 		 * Get the name of this card. Iif binding_name is found,
2193156Sgirish 		 * name will be <nodename>-<binding_name>
2203156Sgirish 		 */
2213156Sgirish 
2223156Sgirish 		err = picl_get_propval_by_name(nodeh, PICL_PROP_BINDING_NAME,
2233156Sgirish 		    &binding_name, sizeof (binding_name));
2243156Sgirish 		if (err == PICL_PROPNOTFOUND) {
2253156Sgirish 			/*
2263156Sgirish 			 * if compatible prop is found, name will be
2273156Sgirish 			 * <nodename>-<compatible>
2283156Sgirish 			 */
2293156Sgirish 			err = huron_get_first_compatible_value(nodeh,
2303156Sgirish 			    &compatible);
2313156Sgirish 			if (err == PICL_SUCCESS) {
2323156Sgirish 				(void) strlcat(name, "-", MAXSTRLEN);
2333156Sgirish 				(void) strlcat(name, compatible, MAXSTRLEN);
2343156Sgirish 				free(compatible);
2353156Sgirish 			} else if (err != PICL_PROPNOTFOUND) {
2363156Sgirish 				return (err);
2373156Sgirish 			}
2383156Sgirish 		} else if (err != PICL_SUCCESS) {
2393156Sgirish 			return (err);
2403156Sgirish 		} else if (strcmp(name, binding_name) != 0) {
2413156Sgirish 			(void) strlcat(name, "-", MAXSTRLEN);
2423156Sgirish 			(void) strlcat(name, binding_name, MAXSTRLEN);
2433156Sgirish 		}
2443156Sgirish 
2453156Sgirish 		(void) strlcpy(pci_card.name, name, sizeof (pci_card.name));
2463156Sgirish 
2473156Sgirish 		/* Get the model of this card */
2483156Sgirish 
2493156Sgirish 		err = picl_get_propval_by_name(nodeh, OBP_PROP_MODEL,
2503156Sgirish 		    &model, sizeof (model));
2513156Sgirish 		if (err == PICL_PROPNOTFOUND)
2523156Sgirish 			(void) strcpy(model, "");
2533156Sgirish 		else if (err != PICL_SUCCESS)
2543156Sgirish 			return (err);
2553156Sgirish 		(void) strlcpy(pci_card.model, model, sizeof (pci_card.model));
2563156Sgirish 
2573156Sgirish 		/* Print NAC name */
2583156Sgirish 		log_printf("%-11s", pci_card.status);
2593156Sgirish 		/* Print IO Type */
2603156Sgirish 		log_printf("%6s", pci_card.bus_type);
2613156Sgirish 		/* Print Slot # */
2623156Sgirish 		log_printf("%5s", pci_card.slot_str);
2633156Sgirish 		/* Print Parent Path */
2643156Sgirish 		log_printf("%46.45s", pci_card.notes);
2653156Sgirish 		/* Printf Card Name */
2663156Sgirish 		if (strlen(pci_card.name) > 24)
2673156Sgirish 			log_printf("%25.24s+", pci_card.name);
2683156Sgirish 		else
2693156Sgirish 			log_printf("%26s", pci_card.name);
2703156Sgirish 		/* Print Card Model */
2713156Sgirish 		if (strlen(pci_card.model) > 10)
2723156Sgirish 			log_printf("%10.9s+", pci_card.model);
2733156Sgirish 		else
2743156Sgirish 			log_printf("%10s", pci_card.model);
2753156Sgirish 		log_printf("\n");
2763156Sgirish 
2773156Sgirish 		err = picl_get_propval_by_name(nodeh, PICL_PROP_PEER, &nodeh,
2783156Sgirish 		    sizeof (picl_nodehdl_t));
2793156Sgirish 
2803156Sgirish 	}
2813156Sgirish 
2823156Sgirish 	return (PICL_WALK_CONTINUE);
2833156Sgirish }
2843156Sgirish 
2853156Sgirish /*
2863156Sgirish  * local functions
2873156Sgirish  */
2883156Sgirish /*
2893156Sgirish  * add all io devices under pci in io list
2903156Sgirish  */
2913156Sgirish /* ARGSUSED */
2923156Sgirish int
huron_hw_rev_callback(picl_nodehdl_t pcih,void * args)2933156Sgirish huron_hw_rev_callback(picl_nodehdl_t pcih, void *args)
2943156Sgirish {
2953156Sgirish 	int		err = PICL_SUCCESS;
2963156Sgirish 	char		path[MAXSTRLEN] = "";
2973156Sgirish 	char		device_path[MAXSTRLEN];
2983156Sgirish 	char		NAC[MAXSTRLEN];
2993156Sgirish 	char		*compatible;
3003156Sgirish 	int32_t		revision;
3013156Sgirish 	int		device_found = 0;
3023156Sgirish 
3033156Sgirish 	err = picl_get_propval_by_name(pcih, PICL_PROP_DEVFS_PATH, path,
3043156Sgirish 	    sizeof (path));
3053156Sgirish 	if (err != PICL_SUCCESS) {
3063156Sgirish 		return (err);
3073156Sgirish 	}
3083156Sgirish 
3093156Sgirish 	if ((strcmp(path, HURON_NETWORK_0) == 0) ||
3103156Sgirish 	    (strcmp(path, HURON_NETWORK_1) == 0)) {
3113156Sgirish 		device_found = 1;
3123156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d",
313*6954Smb158278 		    MOTHERBOARD, OPHIR, 0);
3143156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3153156Sgirish 		    &err);
3163156Sgirish 	}
3173156Sgirish 
3183156Sgirish 	if ((strcmp(path, HURON_NETWORK_2) == 0) ||
3193156Sgirish 	    (strcmp(path, HURON_NETWORK_3) == 0)) {
3203156Sgirish 		device_found = 1;
3213156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s%d", MOTHERBOARD,
322*6954Smb158278 		    OPHIR, 1);
3233156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3243156Sgirish 		    &err);
3253156Sgirish 	}
3263156Sgirish 
3273156Sgirish 	if (strcmp(path, HURON_SWITCH_A_PATH) == 0) {
3283156Sgirish 		device_found = 1;
3293156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s",
330*6954Smb158278 		    MOTHERBOARD, HURON_SWITCH_A);
3313156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3323156Sgirish 		    &err);
3333156Sgirish 	}
3343156Sgirish 
3353156Sgirish 	if (strcmp(path, HURON_SWITCH_B_PATH) == 0) {
3363156Sgirish 		device_found = 1;
3373156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
338*6954Smb158278 		    HURON_SWITCH_B);
3393156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3403156Sgirish 		    &err);
3413156Sgirish 	}
3423156Sgirish 
3433156Sgirish 	if (strcmp(path, HURON_SWITCH_C_PATH) == 0) {
3443156Sgirish 		device_found = 1;
3453156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
346*6954Smb158278 		    HURON_SWITCH_C);
3473156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3483156Sgirish 		    &err);
3493156Sgirish 	}
3503156Sgirish 
3513156Sgirish 	if (strcmp(path, HURON_LSI_PATH) == 0) {
3523156Sgirish 		device_found = 1;
3533156Sgirish 		(void) snprintf(NAC, sizeof (NAC), "%s/%s", MOTHERBOARD,
3543156Sgirish 		    SAS_SATA_HBA);
3553156Sgirish 		revision = huron_get_int_propval(pcih, OBP_PROP_REVISION_ID,
3563156Sgirish 		    &err);
3573156Sgirish 	}
3583156Sgirish 	if (device_found == 1) {
3593156Sgirish 		(void) strcpy(device_path, path);
3603156Sgirish 		err = huron_get_first_compatible_value(pcih, &compatible);
3613156Sgirish 
3623156Sgirish 		/* Print NAC name */
3633156Sgirish 		log_printf("%-20s", NAC);
3643156Sgirish 		/* Print Device Path */
3653156Sgirish 		if (strlen(device_path) > 45)
3663156Sgirish 			log_printf("%45.44s+", device_path);
3673156Sgirish 		else
3683156Sgirish 			log_printf("%46s", device_path);
3693156Sgirish 		/* Print Compatible # */
370*6954Smb158278 		if (err == PICL_SUCCESS) {
371*6954Smb158278 			log_printf("%31s", compatible);
372*6954Smb158278 			free(compatible);
373*6954Smb158278 		} else
374*6954Smb158278 			log_printf("%31s", " ");
3753156Sgirish 		/* Print Revision */
3763156Sgirish 		log_printf("%6d", revision);
3773156Sgirish 		log_printf("\n");
3783156Sgirish 	}
3793156Sgirish 
3803156Sgirish 	return (PICL_WALK_CONTINUE);
3813156Sgirish }
3823156Sgirish 
3833156Sgirish /*
3843156Sgirish  * return the first compatible value
3853156Sgirish  */
3863156Sgirish int
huron_get_first_compatible_value(picl_nodehdl_t nodeh,char ** outbuf)3873156Sgirish huron_get_first_compatible_value(picl_nodehdl_t nodeh, char **outbuf)
3883156Sgirish {
3893156Sgirish 	int		err;
3903156Sgirish 	picl_prophdl_t	proph;
3913156Sgirish 	picl_propinfo_t	pinfo;
3923156Sgirish 	picl_prophdl_t	tblh;
3933156Sgirish 	picl_prophdl_t	rowproph;
3943156Sgirish 	char		*pval;
3953156Sgirish 
3963156Sgirish 	err = picl_get_propinfo_by_name(nodeh, OBP_PROP_COMPATIBLE,
3973156Sgirish 	    &pinfo, &proph);
3983156Sgirish 	if (err != PICL_SUCCESS)
399*6954Smb158278 		return (err);
4003156Sgirish 
4013156Sgirish 	if (pinfo.type == PICL_PTYPE_CHARSTRING) {
4023156Sgirish 		pval = malloc(pinfo.size);
4033156Sgirish 		if (pval == NULL)
4043156Sgirish 			return (PICL_FAILURE);
4053156Sgirish 		err = picl_get_propval(proph, pval, pinfo.size);
4063156Sgirish 		if (err != PICL_SUCCESS) {
4073156Sgirish 			free(pval);
4083156Sgirish 			return (err);
4093156Sgirish 		}
4103156Sgirish 		*outbuf = pval;
4113156Sgirish 		return (PICL_SUCCESS);
4123156Sgirish 	}
4133156Sgirish 
4143156Sgirish 	if (pinfo.type != PICL_PTYPE_TABLE)
4153156Sgirish 		return (PICL_FAILURE);
4163156Sgirish 
4173156Sgirish 	/* get first string from table */
4183156Sgirish 	err = picl_get_propval(proph, &tblh, pinfo.size);
4193156Sgirish 	if (err != PICL_SUCCESS)
4203156Sgirish 		return (err);
4213156Sgirish 
4223156Sgirish 	err = picl_get_next_by_row(tblh, &rowproph);
4233156Sgirish 	if (err != PICL_SUCCESS)
4243156Sgirish 		return (err);
4253156Sgirish 
4263156Sgirish 	err = picl_get_propinfo(rowproph, &pinfo);
4273156Sgirish 	if (err != PICL_SUCCESS)
428*6954Smb158278 		return (err);
4293156Sgirish 
4303156Sgirish 	pval = malloc(pinfo.size);
4313156Sgirish 	if (pval == NULL)
4323156Sgirish 		return (PICL_FAILURE);
4333156Sgirish 
4343156Sgirish 	err = picl_get_propval(rowproph, pval, pinfo.size);
4353156Sgirish 	if (err != PICL_SUCCESS) {
4363156Sgirish 		free(pval);
4373156Sgirish 		return (err);
4383156Sgirish 	}
4393156Sgirish 
4403156Sgirish 	*outbuf = pval;
4413156Sgirish 	return (PICL_SUCCESS);
4423156Sgirish }
4433156Sgirish 
4443156Sgirish int64_t
huron_get_int_propval(picl_nodehdl_t modh,char * prop_name,int * ret)4453156Sgirish huron_get_int_propval(picl_nodehdl_t modh, char *prop_name, int *ret)
4463156Sgirish {
4473156Sgirish 	int		err;
4483156Sgirish 	picl_prophdl_t	proph;
4493156Sgirish 	picl_propinfo_t	pinfo;
4503156Sgirish 	int8_t		int8v;
4513156Sgirish 	int16_t		int16v;
4523156Sgirish 	int32_t		int32v;
4533156Sgirish 	int64_t		int64v;
4543156Sgirish 
4553156Sgirish 	err = picl_get_propinfo_by_name(modh, prop_name, &pinfo, &proph);
4563156Sgirish 	if (err != PICL_SUCCESS) {
4573156Sgirish 		*ret = err;
4583156Sgirish 		return (0);
4593156Sgirish 	}
4603156Sgirish 
4613156Sgirish 	/*
4623156Sgirish 	 * If it is not an int, uint or byte array prop, return failure
4633156Sgirish 	 */
4643156Sgirish 	if ((pinfo.type != PICL_PTYPE_INT) &&
465*6954Smb158278 	    (pinfo.type != PICL_PTYPE_UNSIGNED_INT) &&
466*6954Smb158278 	    (pinfo.type != PICL_PTYPE_BYTEARRAY)) {
4673156Sgirish 		*ret = PICL_FAILURE;
4683156Sgirish 		return (0);
4693156Sgirish 	}
4703156Sgirish 
4713156Sgirish 	switch (pinfo.size) {
4723156Sgirish 	case sizeof (int8_t):
4733156Sgirish 		err = picl_get_propval(proph, &int8v, sizeof (int8v));
4743156Sgirish 		*ret = err;
4753156Sgirish 		return (int8v);
4763156Sgirish 	case sizeof (int16_t):
4773156Sgirish 		err = picl_get_propval(proph, &int16v, sizeof (int16v));
4783156Sgirish 		*ret = err;
4793156Sgirish 		return (int16v);
4803156Sgirish 	case sizeof (int32_t):
4813156Sgirish 		err = picl_get_propval(proph, &int32v, sizeof (int32v));
4823156Sgirish 		*ret = err;
4833156Sgirish 		return (int32v);
4843156Sgirish 	case sizeof (int64_t):
4853156Sgirish 		err = picl_get_propval(proph, &int64v, sizeof (int64v));
4863156Sgirish 		*ret = err;
4873156Sgirish 		return (int64v);
4883156Sgirish 	default:	/* not supported size */
4893156Sgirish 		*ret = PICL_FAILURE;
4903156Sgirish 		return (0);
4913156Sgirish 	}
4923156Sgirish }
493